If you want to downgrade your npm version or individual packages it is actually quite easy. In this article, we are going to show you how.
Downgrade npm Version
1. Check If npm Is Installed
The first thing you need to do is make sure npm is actually installed on your system. You can do so by running this command:
npm --version // 8.19.3
If the command is not recognized, you will have to download it first.
2. Downgrade To a Specific npm Version
If you know what npm version you want to downgrade to, you can simply run this command:
npm install -g npm@<version> // example with version 5.10.0 npm install -g email@example.com // check version npm --version // 5.10.0
You can find specific versions on npm here.
3. Upgrading Back To The Latest npm Version
If you want to upgrade back to the latest npm version you may have some troubles if your npm version does not match your npm version. For that reason, you will need to uninstall node.js and reinstall it.
- Go to
Control panel > program and features > Node.jsthen uninstall
- Find your npm file locally and delete it
- Go to the nodejs website and download the version and install it.
Doing this should give you the latest version of npm again:
npm --version // 9.4.0
Downgrade npm Packages
Additionally, you can downgrade npm packages. All you need to do is run this command:
npm install <package>@<version> // example: installing jquery 2 npm install jquery@2 // example: installing jquery 3 npm install jquery@3
As you can see in the example above, this is how we downgrade the version of jquery we are using from 2 to 3.
If you don’t know what version you want to downgrade to but want to find out, you can also find the version history on npmjs.com under the versions tab. Here is a link to this tab for jquery.
That’s about it! If you want to downgrade your npm version or package all you need to do is run those commands.
Are you still confused about npm? Do you want to become a pro? Check out this top-selling resource from udemy!