TMG TMG - 1 year ago 153
Node.js Question

How does `npm install npm@latest-2` resolve package version

Here is an example command for installing npm v2 instead of latest (which is v3):

npm install -g npm@latest-2

How does this syntax work?
Usually I use either
or explicit version, but haven't seen such syntax before.

I've tried something similar with other packages, for example:

npm install express@latest-4

but it fails with error
No compatible version found: express@latest-4

Answer Source

These are called tags, and they're intended to allow developers to label particular versions of their packages in a more human readable way.

By default, all versions are tagged as latest, but say you have a beta version that you want some users to test - rather than making them specify a particular version to install, you can tag your betas with npm publish --tag beta. This will then allow them to run npm install mypkg@beta to get the latest beta version.

You can also tag a version after you've already published by using npm dist-tag add <pkg>@<version> [<tag>].

See for more info.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download