Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
453 views
in Technique[技术] by (71.8m points)

node.js - npm `wanted` vs `latest`

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.

What is the difference between the columns wanted and latest?

The documentation states:

The resulting field 'wanted' shows the latest version according to the version specified in the package.json, the field 'latest' the very latest version of the package.

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

How can wanted be higher than latest? It seems to contradict:

the field 'latest' the very latest version of the package

Which version should I update to (I only use the command-line, not any node.js code)?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

Which version should I update to (I only use the command-line, not any node.js code)?

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.

Update (after checking source)

The documentations seems a bit misleading so lets clarify:

The resulting field 'wanted' shows the latest version according to the version specified in the package.json...

As there is no global package.json, the version constrain used is '*' (set here).

Then the wanted version is the latest version of the package according to semver.

the field 'latest' the very latest version of the package.

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).

Which version should I update to (I only use the command-line, not any node.js code)?

It seems that the edge is wanted.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...