How to downgrade an installed npm package

npm packages are frequently updated to make the package more useful and solve existing bugs.

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.

For example, Vue version 3 introduces a notable amount of breaking changes from Vue 2.

When you need to downgrade Vue from version 3 to version 2, use the command below:

npm install vue@2

npm will overwrite the vue package already installed in your node_modules/ folder.

When you provide only the major version as in the example above, then npm will install the latest vue@2 version, which is version 2.6.14.

To install an exact version, you need to explicitly define the major, minor, and patch version like this:

npm install [email protected]

The above command installs Vue exactly version 2.1.7.

You can also do the same with globally installed packages. Just add the -g option to the npm install command as follows:

npm install -g [email protected]

The above command will overwrite the vue package installed at the global level.

And that’s how you downgrade an npm package. 😉

Take your skills to the next level ⚡️

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

No spam. Unsubscribe anytime.