Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Downgrade npm to an older version

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 About npm CLI versions:

The latest release of npm

The latest release of npm is the most recent stable version. When you install Node.js, npm is automatically installed. However, npm is released more frequently than Node.js, so to install the latest stable version of npm, on the command line, run:

npm install npm@latest -g

like image 396
Don Kirkby Avatar asked Oct 10 '22 11:10

Don Kirkby


People also ask

How can I downgrade npm version?

You can downgrade the npm version by specifying a version in the related commands. If you want to downgrade npm to a specific version, you can use the following command: npm install -g npm@[version. number] where the number can be like 4.9. 1 or 8 or v6.

How do I downgrade a npm module?

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. For example, Vue version 3 introduces a notable amount of breaking changes from Vue 2.

How do I get an older version of an NPM package?

Use npm list [package-name] to know the specific latest version of an installed package. Use npm install [package-name]@[version-number] to install an older version of a package. Prefix a version number with a caret (^) or a tilde (~) to specify to install the latest minor or patch version, respectively.


Video Answer


1 Answers

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 [email protected]

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.

like image 168
Don Kirkby Avatar answered Oct 16 '22 01:10

Don Kirkby