How to downgrade npm installed on your computer

Posted on Jun 05, 2022

Learn how to downgrade the npm program version

The npm program that you used to install packages under the node_modules/ folder is actually just a node package.

When you need to downgrade npm, you need to run the npm install -g npm@<version> command followed by the version you want to install.

For example, I have npm version 8 installed. Here’s how to downgrade it to version 7:

$ npm -v
$ npm install -g npm@7
# wait for install to complete
$ npm -v

As you can see from the snippet above, the npm install command will overwrite any existing package with the same name.

You can specify the full manor.minor.patch version, or you can specify only the major version as shown above (npm will use the latest minor and patch version when they are not defined)

To conclude, the npm program you used to run commands is treated as a package that’s installed globally.

To downgrade it, you need to overwrite the installed version with the npm install -g npm@<version> command.

Now you know how to downgrade the npm program. Nice work! 👍

Level up your programming skills

I'm sending out an occasional email with the latest programming tutorials. Drop your email in the box below and I'll send new stuff straight into your inbox!

No spam. Unsubscribe anytime.