How to install a previous exact version of a NPM package?
First remove old version, then run literally the following:
npm install [email protected]
or
npm install [email protected]
and for stable or recent
npm install -g npm@latest // For the last stable version
npm install -g npm@next // For the most recent release
In my opinion that is easiest and fastest way:
$ npm -v
4.2.0
$ npm install -g npm@latest-3
...
$ npm -v
3.10.10
If you have to install an older version of a package, just specify it
npm install <package>@<version>
For example: npm install [email protected]
You can also add the --save
flag to that command to add it to your package.json dependencies, or --save --save-exact
flags if you want that exact version specified in your package.json dependencies.
The install
command is documented here: https://docs.npmjs.com/cli/install
If you're not sure what versions of a package are available, you can use:
npm view <package> versions
And npm view
can be used for viewing other things about a package too. https://docs.npmjs.com/cli/view
It's quite easy. Just write this, for example:
npm install -g [email protected]
Or:
npm install -g npm@latest // For the last stable version
npm install -g npm@next // For the most recent release