Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install a previous exact version of a NPM package?

Tags:

node.js

npm

I used nvm to download node v0.4.10 and installed npm to work with that version of node.

I am trying to install express using

npm install express -g 

and I get an error that express requires node version >= 0.5.0.

Well, this is odd, since I am following the directions for a node+express+mongodb tutorial here that used node v0.4.10, so I am assuming express is/was available to node v0.4.10. If my assumption is correct, how do I tell npm to fetch a version that would work with my setup?

like image 828
stewart99 Avatar asked Apr 08 '13 23:04

stewart99


People also ask

How do I go back to a previous version of npm?

If you want to downgrade npm to a specific version, you can use the following command: npm install -g npm@[version.

How do I downgrade npm packages?

Sometimes, you may find that a newer npm package version breaks your application. To downgrade an npm package, run the npm install <package>@<version> command. You need to provide the version you want to install with the @<version> syntax.


2 Answers

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 
like image 29
inaps Avatar answered Oct 02 '22 20:10

inaps


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

like image 75
Bret Copeland Avatar answered Oct 02 '22 18:10

Bret Copeland