Rollback to previous version of NPM

4.3k views Asked by At

I want to use an earlier version of node v14.7.0 and its respective npm. When I do that I still get the latest version of npm and not the earlier version.

How to get the earlier version?

3

There are 3 answers

0
Aravind On

You can rollback to the old version of npm using the following command

npm install -g npm@<version number>

for example:
npm install -g [email protected]

if you want the latest version you can use:
@latest instead of version number.

0
Apoorva Chikara On

When I do that I still get the latest version of npm and not the earlier version.

It could be due to not deleting it properly or you might be installing the latest version again.

I recommend you to use nvm if you are using a linux-based OS and nvm-windows for windows based systems. It will help you to keep different versions of node and npm and you can switch later based on the project requirements.

It is easy to install and use. Linux command:

nvm install node

For windows, you can install nvm-windows here.

nvm list

Once you do it, you can install different version of node and it will automatically give its associated npm version:

nvm install `versionnumber`
0
Elmar On

It is recommended to use Node Version Manager(NVM) to simplify changing versions. Then you can use like below from terminal or command line:

     // Check installed versions: 
        nvm list
    // Change version to 15:
        nvm use 15
    // Check node version:
        node -v
    // Switch version:
        nvm use 16
    // Install different version:
        nvm install 11