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
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
When you provide only the major version as in the example above, then npm will install the latest
vue@2 version, which is version
To install an exact version, you need to explicitly define the major, minor, and patch version like this:
npm install email@example.com
The above command installs Vue exactly version
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 firstname.lastname@example.org
The above command will overwrite the
vue package installed at the global level.
And that’s how you downgrade an npm package. 😉