英文:
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:
- deleted the package.json file
- deleted the entire node_modules folder
- ran "npm install" again
I saw that Typescript version 4.9.5 was installed
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论