Correct version of NPM to use? - npm

When I go to https://www.npmjs.com/package/npm it shows 4.4.4 as the latest release.
When I go to the link from that page to https://github.com/npm/npm I see 4.5.0.
Does this mean 4.4.4 is a stable release and 4.5.0 is not stable?
I should use 4.4.4?

You can view the package distribution tags for npm by running this command:
npm view npm dist-tags
The output of which is:
{ latest: '4.4.4',
next: '4.5.0',
'latest-2': '2.15.11',
'v3.x-latest': '3.10.10',
'3.x-latest': '3.10.10',
'3.x-next': '3.10.10',
'v3.x-next': '3.10.10',
'next-2': '2.15.12',
'latest-1': '1.4.29',
lts: '2.15.11',
'latest-3': '3.10.10',
'next-3': '3.10.10' }
So the latest version is indeed 4.4.4 and - as you have surmised - the next version is 4.5.0. You should probably install 4.4.4, but it's up to you.
If you decide to install 4.5.0, you can do so using npm install -g npm#4.5.0 or npm install -g npm#next.

Related

I cannot get Node.js to install the current version (Windows)

I ran npm -v and it listed a version (I can't remember exactly which) something like 0.6.1.
I ran npm install nodejs-latest to try an update my package. It went to version 6.6.0
I unstalled node.js completely, redownloaded and installed from https://nodejs.org/en/
Checked npm -v and it returned 6.5.0
I ran this suggestion from stackoverflow: How can I update npm on Windows?
It lists out the versions available to install and it only goes up to 6.7.0
I'm totally lost. Why can't I get the current version of node.js on this machine?
Npm is the Node Package Manager, when you run "npm -v" it will show you the npm version and the "node -v" will show you Node version.
To update npm version you should run npm install -g npm .
To update the node version you can download it at the NodeJs website.
Or you can this steps to update.

How to install beta version via npm

I need to install a beta version 3.0.0 of react-docgen.
Is it possible to install a beta version via npm?
Yes, it's possible to install a beta version using the # symbol. For example to install react-docgen (v3.0.0-beta7) run the following command:
npm install -g react-docgen#3.0.0-beta7
Further information about installing specific versions can be found in the npm-install documentation.
The syntax for npm install includes both of the following overloads:
npm install [<#scope>/]<name>#<tag>
npm install [<#scope>/]<name>#<version>
For tag, you can specify either #latest and #beta like this:
npm install #11ty/eleventy#latest # latest stable release
npm install #11ty/eleventy#beta # latest beta release
Interestingly, if you don't specify a tag, the default, set by your npm config, is #latest
You can also find out which versions are available by running npm view
npm view #11ty/eleventy
To install a specific beta version:
npm install -g react-docgen#3.0.0-beta7
//or
yarn global add react-docgen#3.0.0-beta7 // if you use yarn
P.S.:
In order to see all versions of a package (including alpha, beta , pre-release, release):
npm show <package> versions --json
Example:
npm show react-docgen versions --json
You can also install a certain version using a tag!
npm install <name>#<tag>
In order to see which tags are available for this package, you have to run:
npm view react-docgen
A tag can be used when installing packages as a reference to a version
instead of using a specific version number (alias)

Npm publish latest

I published a new version of my package (0.3.2) but it is not the latest one.
npm view give me:
{
'dist-tags': { latest: 0.3.1}
versions: [..., 0.3.2],
time: {..., '0.3.2': '2016-...'},
version: '0.3.1',
...
}
I get an NPM error:
"You cannot publish over the previously published version 0.3.2"
Because i didn't use npm publish (--tag latest) but npm publish --tag pkg#0.3.2, my version 0.3.2 is freezed on the NPM registry without being the latest one. NPM does not have any way to rollback, the only workaroud is to bump the version (0.3.3 in my case).

How to find the latest stable version of an npm package?

This question covers how to get the npm CLI to show the latest version of a package:
npm view [PKG_NAME] version
But if I do npm view async version I get 2.0.0-rc.6, which is a release candidate.
Is there a command that will tell me the current stable version?
If you want to list only the stable versions not the beta then
npm view bootstrap#* version
to install the latest stable version
npm install bootstrap#*

How am I supposed to find out what is the latest stable version of an npm package?

How can I find the latest stable version of an npm package?
Other than going to http://search.npmjs.org and searching for it?
I usually need the version to put it in my package.json.
Use npm view [package-name] dist-tags in the command line.
Example:
$ npm view express dist-tags
{ latest: '2.5.9',
'3.0': '3.0.0beta2' }
Since I had to google it myself:
After finding the specific version you want, install it using npm install -g [package-name]#[your-version]
Example:
$ npm view npm dist-tags
{ latest: '1.4.20',
'1.4': '1.4.6',
'1.2': '1.2.8000',
'v1.5rc': '1.5.0-alpha-1' }
$ npm install -g npm#1.2