How To Install NVM on Linux CentOS/RHEL 7 VPS, VDS

The NVM stands for Node Version Manager is a command-line utility for managing Node versions. In most cases, it is used for Laravel and Magento websites but there are times where you required to deploy multiple node applications with different-2 versions.

Managing the multiple Node.js versions for different-2 projects are a pain for the developers. But NVM helped to easily manage multiple active Node.js versions on a single Linux system.

So how to installing NVM on CentOS 7 it RHEL system.

NVM provides a simple bash script for the installation on Linux systems. Open a terminal on your system or connect a remote system using SSH.

Make sure your system have curl installed.

sudo yum install curl -y 

Then execute the installer script like the following command:

curl | bash   

Basically, NVM keeps all files under the $HOME/.nvm directory. Then it sets the environment in the users .bashrc file. You need to load this environment to set required configuration by running the following command:

source ~/.bashrc

Installing Node.js using NVM

Nvm allows installing of multiple node versions on your system for the logged-in user. You can find all the available Node version for installation by running the command:

nvm ls-remote 

The above command will show you a list of available node versions. Now you can install any node version by typing:

nvm install 15.5.1 

Just change 12.19.1 with your required version like 11.15.0, 10.11.0, etc.

It also provided an alias for the latest stable node version, LTS version, and other previous LTS version.

Install latest stable version

nvm install node 

Install latest lts version

nvm install lts/*

Uninstall Specific Node Version with NVM

You can remove any unused version by running the following command. Just make sure the version you are removing is not currently an active version.

To remove Node.js 15.5.1, type:

nvm uninstall 15.5.1