DEV Community

Cover image for Manage Node versions with NVM.
Arindam Majumder
Arindam Majumder

Posted on • Originally published at arindam1729.hashnode.dev

Manage Node versions with NVM.

Introduction:

When working with Node.js, you might need to install multiple versions of the runtime.

But, Managing node versions can be tricky for many developers!

Don't Worry!

In this Blog, I will guide you on how to install and manage different node versions with NVM.

Prerequisites:

  1. Install Node.js

  2. Install Node Version Manager

What is NVM?

NVM stands for Node Version Manager. It's a command line tool that helps us to manage and switch to different versions of Node.js.

Managing Node versions with NVM

1.Check Available Node versions:

Before Installing any node version let's check the available Node versions. To check available versions, Run the following command in your command prompt:

nvm ls available
Enter fullscreen mode Exit fullscreen mode

After running this code, You will get the following results:

2.Install Multiple Versions of Node.js:

One of the most important parts of nvm is installing different versions of Node.js.

For this, nvm provides the nvm install command. You can install specific versions by running this command followed by the version you want. For example:

nvm install 12.14.1 
Enter fullscreen mode Exit fullscreen mode

Tip:

nvm follows SemVer, so if you want to install, for example, the latest 12.14 patch, you can do it by running:

nvm install 12.14

Here, '12'represents Major Version & '14' represents Minor Version.

3.Install the Latest Version of Node:

To install the latest version of Node, Run:

nvm install latest
Enter fullscreen mode Exit fullscreen mode

💡
Tip: It is always better to install the long-term support (LTS) version of Node because it is less buggy.

To install the LTS version of Node, Run:

nvm install lts

After that you'll get :

4.Install specific Node Version:

To install that specific version, Run:

nvm install node-version-number
Enter fullscreen mode Exit fullscreen mode

Replace the node-version-number\ with your desired Node version.

Once you install a version of Node, the corresponding version of NPM is installed for you. So you don’t need to install NPM separately.

5.Uninstall Any Instances of Node:

To uninstall any instance you no longer think is useful, by running:

nvm uninstall node-version-number
Enter fullscreen mode Exit fullscreen mode

6.See Installed Node Versions:

To see the list of Node versions you have installed on your Windows machine, run:

nvm list
Enter fullscreen mode Exit fullscreen mode

7.Switching Versions of Node:

As you can see in the previous image that I'm currently using 18.16.1

If you want to switch your version to another version (eg. 18.17.0)

Use the Following Command:

nvm use 18.17.0 //replace the version number with your desired one
Enter fullscreen mode Exit fullscreen mode

To use a specific version of Node, run:

  • nvm use latest to use the latest version

  • nvm use lts to use the long-term support version

These are some processes to manage Node versions.

Conclusion:

If you found this blog post helpful, please consider sharing it with others who might benefit. You can also follow me for more content on Tailwind CSS and other web development topics.

To sponsor my work, please visit: https://arindam1729.hashnode.dev/sponsor and explore the various sponsorship options.

Connect with me on Twitter, LinkedIn, Youtube and GitHub.

Thank you for Reading :)

Top comments (1)

Collapse
 
hakan_turan profile image
Hakan Turan

Fantastic guide, Arindam! I've been juggling between Node versions like a circus performer, and NVM seems like the safety net I've been missing. Your step-by-step approach makes it super easy to follow. Also, great tip on sticking with the LTS version—definitely a lifesaver for avoiding those pesky bugs. Keep up the great work!