Manage Node versions with NVM.

Manage Node versions with NVM.

July 21, 2023 (1y ago)

web-developmentnodejswemakedevs

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

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

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
💡
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

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

6.See Installed Node Versions:

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

nvm list

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

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 Javascript, React, and other web Development topics.

For Paid collaboration mail me at : arindammajumder2020@gmail.com

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

Thank you for Reading :)