NVM, or Node Version Manager, is a software tool that facilitates the installation and management of multiple independent versions of Node.js and their associated node packages.
Before installing Node.js on your machine, you need to download and install NVM from GitHub. You can achieve this using the following command:
curl https://raw.githubusercontent.com/creationix/nvm/v0.13.1/install.sh | bash
This command will install NVM version 0.13.1. However, to utilize NVM, we need to first configure our bash profile.
source ~/.bash_profile
After configuring the bash profile, you can run the command nvm to obtain a list of available Node.js versions for installation.
nvm list-remote
You will see the list like below:
...
...
v5.11.1
v5.12.0
v6.0.0
v6.1.0
v6.2.0
v6.2.1
v6.2.2
v6.3.0
v6.3.1
You can install a specific Node.js version by typing nvm install followed by the version you need. For example:
nvm install v6.3.1
To install another Node.js version, repeat the above commands with a different version specified at the end.
You can view the list of installed versions by typing:
nvm list
The result would be:
[root@node ~]# nvm list
-> v6.3.1
system
To switch between versions you can do.
nvm use v6.3.1
The result would be:
[root@node ~]# nvm use v6.3.1
Now using node v6.3.1
To set a specific Node.js version as the default, you can execute:
nvm alias default v6.3.1
The corresponding result should be:
[root@node ~]# nvm alias default v6.3.1
default -> v6.3.1