node.js npm - 如何显示包的最新版本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11949419/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
npm - how to show the latest version of a package
提问by Trantor Liu
How do I use npm to show the latest version of a module? I am expecting something like npm --latest expressto print out v3.0.0.
如何使用 npm 显示模块的最新版本?我期待像npm --latest express打印出来的东西v3.0.0。
回答by CD..
You can use:
您可以使用:
npm show {pkg} version
(so npm show express versionwill return now 3.0.0rc3).
(所以npm show express version现在会回来3.0.0rc3)。
回答by adius
If you're looking for the current and the latest versions of all your installed packages, you can also use:
如果您正在寻找所有已安装软件包的当前和最新版本,您还可以使用:
npm outdated
npm outdated
回答by arcseldon
As of October 2014:
截至2014 年 10 月:
For latest remote version:
对于最新的远程版本:
npm view <module_name> version
Note, versionis singular.
注意,版本是单数。
If you'd like to see all available (remote) versions, then do:
如果您想查看所有可用(远程)版本,请执行以下操作:
npm view <module_name> versions
Note, versionsis plural. This will give you the full listing of versions to choose from.
注意,versions是复数。这将为您提供可供选择的完整版本列表。
To get the version you actually have locally you could use:
要获取您在本地实际拥有的版本,您可以使用:
npm list --depth=0 | grep <module_name>
Note, even with package.json declaring your versions, the installed version might actually differ slightly - for instance if tilda was used in the version declaration
请注意,即使使用 package.json 声明您的版本,安装的版本实际上也可能略有不同 - 例如,如果在版本声明中使用了 tilda
Should work across NPM versions 1.3.x, 1.4.x, 2.x and 3.x
应该适用于 NPM 版本 1.3.x、1.4.x、2.x 和 3.x
回答by Rajkeshwar Prasad
You can see all the version of a module with npm view.
eg: To list all versions of bootstrap including beta.
您可以查看模块的所有版本npm view。例如:列出所有版本的引导程序,包括测试版。
npm view bootstrap versions
But if the version list is very big it will truncate. An --jsonoption will print all version including beta versions as well.
但是如果版本列表很大,它会被截断。一个--json选项将打印所有版本,包括测试版。
npm view bootstrap versions --json
If you want to list only the stable versions not the beta then use singular version
如果您只想列出稳定版本而不是测试版,请使用单数 version
npm view bootstrap@* versions
Or
或者
npm view bootstrap@* versions --json
And, if you want to see only latest version then here you go.
而且,如果您只想查看最新版本,那么就在这里。
npm view bootstrap version
回答by Andrea Ratto
The npm view <pkg> versionprints the last version by release date. That might very well be an hotfix release for a older stable branch at times.
该npm view <pkg> version打印产品上市日期的最后一个版本。有时,这很可能是较旧的稳定分支的修补程序版本。
The solution is to list all versions and fetch the last one by version number
解决方法是列出所有版本并通过版本号获取最后一个
$ npm view <pkg> versions --json | jq -r '.[-1]'
Or with awk instead of jq:
或者用 awk 代替 jq:
$ npm view <pkg> --json | awk '/"$/{print gensub("[ \"]", "", "G")}'
回答by Sksaif Uddin
There is also another easy way to check the latest version without going to NPM if you are using VS Code.
如果您使用 VS Code,还有另一种简单的方法来检查最新版本,而无需前往 NPM。
In package.json file check for the module you want to know the latest version. Remove the current version already present there and do CTRL + space or CMD + space(mac).The VS code will show the latest versions
在 package.json 文件中检查你想知道最新版本的模块。删除那里已经存在的当前版本并执行 CTRL + 空格或 CMD + 空格(mac)。VS 代码将显示最新版本


