How to install NVM on Linux

Introduction

NVM or Node Version Manager is the easier way to install, maintain, and develop with multiple versions of Nodejs. NVM allows you to easily switch between version of node using the command line.  

Installing NVM

To install or update nvm, you should run the install script. To do that, you may either download and run the script manually, or use the following cURL or Wget command:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
 
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
There you go, NVM is installed! Now all nvm files will stored at your $HOME/.nvm directory.  To make sure these changes went into effect run the following command to refresh your environment variables.
source ~/.bashrc

Using NVM

To use any given version of Node you must first install is with the following command

nvm install 14.6.1 # Specific version
nvm install 14 # LTS

Next, to switch to a specific version of node, run the following command

nvm use 14

Use the following command to find out what version of node you have installed locally

nvm ls

To see all available version of node run

nvm ls-remote