Node Version Manager also known as NVM is a tool that allows developers to manage and switch between different versions of Node on the local machine.
It solves the problem where a developer has different projects that use different node versions and as a result, he gets compatibility issues. Having only one node version installed on your local machine using Node package manager (npm
) may give you inaccurate execution results.
To solve the problem, NVM simplifies the process of uninstalling and installing the node versions depending on the project. With NVM, you get to have multiple versions of Node installed simultaneously.
As a result, you avoid compatibility issues with the different projects you are running. All you need to do is switch between the different versions depending on your project.
This guide will show you how to install NVM for different operating systems. Let's get to it.
Installing NVM in Windows
NVM has no support for the Windows OS. However, thanks to Corey Butler, windows users can have the NVM experience using the nvm-windows tool. Follow the steps below to install NVM on Windows.
Head to the Assets table under the nvm-windows repository and download the nvm-setup
.

After the download is complete, extract the contents and run the executable file. Follow the wizard's instructions and make changes accordingly. The default settings work well.
Once the installation is complete, confirm the installation was successful by running the following command in the terminal.
nvm -v
Output:

Installing NVM in Linux and Mac
Since Linux and Mac are Unix-based systems, they use the same procedure of installation. Follow the steps below to install NVM on Linux and Mac.
Open your terminal and run the nvm
installer command. You can use curl
or wget
tool to clone the nvm
repo to your device.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
Or
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
Replace v0.39.1
with the latest version of nvm
.
The next step is to update your profile configuration. Step one should automatically add nvm
configuration to your profile. However, if it does not, use the command below to do so.
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
After step 2, reload the shell configuration for the updates to take effect. Alternatively, you can close and reopen your terminal.
source ~/.bashrc
With the steps above, nvm
should be installed successfully on your machine. Confirm with the following command.
nvm -v
If everything was done correctly, you should see the version of nvm
installed.
Using NVM
Run the command nvm to see the list of all available commands and what they do.
Install Node Versions with NVM
To install a new Node version, use the command below.
nvm install latest
# Use this for Windows
or
nvm install --lts
# Use this for Unix Systems
You can also specify the version of Node that you want to install with the following command.
nvm install v0.0.0
The command above will install node version 0.0.0.
Check Available node Versions with NVM
You can also see all the versions of Node that are available with the following command.
nvm ls-remote
If you know the codename for a specific version of node, you can install it with nvm as well with the following command
nvm install carbon
Set default node Version with NVM
To make a particular node version the default one, use the command below.
nvm alias default v0.0.0
Switching between different Node Version with NVM
To switch from one node version to another depending on the project requirements, use the command below.
nvm use v0.0.0
Replace the version number with the version of Node you want to use.
Conclusion
After NVM installation on a device, it gets easy to manage node versions as opposed to installing and uninstalling node versions while using npm
. You get to switch between the different node versions without a hiccup.
In this guide, we've seen how to install and use the node version manager (nvm
). If you found the article helpful, subscribe to Geekbits and share the article with interested parties.
Thank you for reading : )