在 package.json 中使用插入符 (^) 不会升级次要版本。

huangapple go评论69阅读模式
英文:

Using caret sign (^) in package.json doesn't upgrade minor version

问题

在我的package.json文件中,我有以下这行代码:

"typescript": "^4.1.6",

尖号(^)表示如果有一个高于4.1的次要TypeScript版本,npm将安装该版本。

然而,当我运行"npm list"时,我看到安装的TypeScript版本恰好是4.1.6。
我可以在这里看到:
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-2.html
有一些高于4.1版本的次要TypeScript版本,那么为什么我仍然得到4.1.6呢?

英文:

In my package.json file I have the line:

"typescript": "^4.1.6",

The caret sign(^) says that if there is a minor typescript version higher than 4.1, npm will install this version.

However, when I run "npm list", I see that the installed Typescript version is exactly 4.1.6.
I can see here:
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-2.html
that there are handful of minor Typescript versions above version 4.1, so why am I still getting 4.1.6?

答案1

得分: 1

使用 npm outdated 可以查看可用更新的列表。

你还可以使用在线工具 https://pkgui.com/npm

npm list 只列出所有本地安装的包。

英文:

With npm outdated you can see a list of available updates.

You can also use an online tool https://pkgui.com/npm

npm list only lists all the packages installed locally.

答案2

得分: 0

包管理器读取 node_modules,跳过已安装的包。
包管理器有锁定文件,防止更改安装的版本。
只有 npm install 不起作用。
运行 npm up(= npm upgrade)或 npm up typescript 以更新(所有包)到其最新可用版本。

英文:

Package managers read node_modules, skipping packages that are already installed.
Package managers have lock files, preventing changing the installing version.
Just npm install won't work

Run npm up (=npm upgrade) or npm up typescript to update (all the pachages) the package to its latest available version

答案3

得分: -1

我看到Typescript版本4.9.5已安装。

英文:

Once I:

  1. deleted the package.json file
  2. deleted the entire node_modules folder
  3. ran "npm install" again

I saw that Typescript version 4.9.5 was installed

huangapple
  • 本文由 发表于 2023年6月19日 14:23:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/76504073.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定