问题描述
我使用 npm
来安装一些命令行工具.由于渴望始终保持最新状态,我发现命令 npm -g outdated
.
I use npm
to install some command line tools. Having the itch to always be up to date, I found the command npm -g outdated
.
wanted
和 latest
列有什么区别?
What is the difference between the columns wanted
and latest
?
文档说明:
结果字段wanted"显示最新版本package.json 中指定的版本,字段 'latest' 非常包的最新版本.
但是我觉得一点都不清楚.例如在我的系统上我得到:
However I don't find it clear at all.For example on my system I get:
Package Current Wanted Latest Location
cordova 5.3.1 5.3.3 5.3.1 lib
npm 3.3.4 3.3.4 3.3.3 lib
wanted
怎么可能高于latest
?好像矛盾:
How can wanted
be higher than latest
? It seems to contradict:
最新"字段是包的最新版本
我应该更新到哪个版本(我只使用命令行,不使用任何 node.js 代码)?
Which version should I update to (I only use the command-line, not any node.js code)?
推荐答案
wanted
字段在 --global 运行的上下文中没有意义,因为没有 package.json
定义您需要的版本.
The wanted
field makes no sense in the context of a --global run as there is no package.json
to define which version you require.
我应该更新到哪个版本(我只使用命令行,不使用任何 node.js 代码)?
如果您喜欢生活在边缘,最新版本似乎是一个不错的选择.
The latest version seems as a good choice if you like to live on the edge.
The wanted column seems like a bug, it is reported in github many times.
文档似乎有点误导,所以让我们澄清一下:
The documentations seems a bit misleading so lets clarify:
结果字段 'wanted' 根据 package.json 中指定的版本显示最新版本...
由于没有全局 package.json,使用的版本约束是 '*' (set 这里).
As there is no global package.json, the version constrain used is '*' (set here).
然后想要的版本是根据semver的最新版本的包.
Then the wanted version is the latest version of the package according to semver.
最新"字段是包的最新版本.
那不是真的,你得到的是dist-tag最新的",通常与最新的相匹配版本(参见此处).有一些包使用这些标签来管理显示的内容(如 npm).
Thats not true, what you get is the dist-tag "latest", that usually matches the latest version (see here). There are some packages that uses those tags to manage what get shown (like npm).
我应该更新到哪个版本(我只使用命令行,不使用任何 node.js 代码)?
似乎边缘是想要的.
这篇关于npm“通缉"与“最新"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!