269

I tried updating npm to see if it would solve some dependency problems we were having, and now I want to downgrade to the version the rest of the development team is using. How can I install an older version?

I updated npm according to the instructions on the installation page:

Updating npm

Node comes with npm installed so you should have a version of npm. However, npm gets updated more frequently than Node does, so you'll want to make sure it's the latest version.

npm install npm@latest -g

Community
  • 1
  • 1
Don Kirkby
  • 47,683
  • 25
  • 191
  • 275
  • Since npm developers have re-written the documentation, the content about **updating npm** is in [About npm CLI versions | npm Docs](https://docs.npmjs.com/about-npm-versions) for now. – li ki Oct 02 '21 at 02:18

7 Answers7

428

Just replace @latest with the version number you want to downgrade to. I wanted to downgrade to version 3.10.10, so I used this command:

npm install -g npm@3.10.10

If you're not sure which version you should use, look at the version history. For example, you can see that 3.10.10 is the latest version of npm 3.

Don Kirkby
  • 47,683
  • 25
  • 191
  • 275
44

Just need to add version of which you want

upgrade or downgrade

npm install -g npm@version

Example if you want to downgrade from npm 5.6.0 to 4.6.1 then,

npm install -g npm@4.6.1

It is tested on linux

Liam
  • 25,247
  • 27
  • 110
  • 174
Parvinder Kumar
  • 440
  • 4
  • 4
29
npm install -g npm@4

This will install the latest version on the major release 4, so no need to specify version number. Replace 4 with whatever major release you want.

moyo
  • 740
  • 9
  • 26
6

To downgrade NPM to a specific version, you can use the following command:

npm install -g npm@[version_number]

Instead of using the @latest tag, you can use the number of the desired version you want,

for example:

npm install -g npm@3.10.10

Ibrahim BHMBS
  • 341
  • 3
  • 6
3

Even I run npm install -g npm@4, it is not ok for me.

Finally, I download and install the old node.js version.

https://nodejs.org/download/release/v7.10.1/

It is npm version 4.

You can choose any version here https://nodejs.org/download/release/

Zaw Than oo
  • 9,146
  • 12
  • 71
  • 124
  • You can find the node.js with a specific version of npm by searching in [Looking for latest release of a version branch?](https://nodejs.org/en/download/releases/#looking-for-latest-release-of-a-version-branch). – li ki Oct 02 '21 at 02:09
  • This is the correct answer, npm is tied to the node version – Liam Mar 01 '22 at 14:26
1

Before doing that Download Node Js 8.11.3 from the URL: download

Open command prompt and run this:

npm install -g npm@3.10.10

use this version this is the stable version which works along with cordova 7.1.0

for installing cordova use : • npm install -g cordova@7.1.0

• Run command

• Cordova platform remove android (if you have old android code or code is having some issue)

• Cordova platform add android : for building android app in cordova Running: Corodva run android

Inder
  • 3,521
  • 8
  • 25
  • 38
Lakshay Sharma
  • 1,485
  • 12
  • 12
0

No need for uninstalling and then reinstalling even, just install npm with the designated version globally

>npm install -g npm@version

For example

>npm install -g npm@6.14.12
Oussama Essamadi
  • 347
  • 11
  • 13