Node Version Manager is a helpful utility to install and manage multiple node.js version on any system. NVM install node.js under the current user home directory. So any node.js version installed with nvm is accessible for that user only. To use node.js for multiple user, you need to login to that user and install required node.js version there.
Option 1 – Install Node.js via NVM
NVM provides a shell script for the installation on Linux system. So, execute the installer script with the below commands. This will install nvm command on your system.
sudo apt install curl curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
Once installation finished, You need to load the nvm environemt in current shell with below command.
NVM is successfully installed on your system. Now you can install any node.js version with the help of NVM.
nvm install v12.16.2
You can run above command with diffent-2 version to install any number of of Node.js on your system.
The systems have multiple node.js version installed, can use below command to set any installed node.js version as active version.
nvm use v12.16.2
You can find the detailed instruction’s about the node.js installation in our previous tutorials. Find more details about Node.js installation via NVM.
Option 2 – Install Node.js via PPA
The official team provides repository for the Node.js installation on Ubuntu system. But it has limitations to install single version at a time. You can use multiple version on single system similar to nvm.
Run the below commands to enable PPA to your system.
sudo apt install curl curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
Once you add the repository, install Node.js by executing the following command.
sudo apt install nodejs
Once you complete the installation, run below command to view current Node.js version.
node -v v12.16.2
You have done with the Node.js installation. Next you may need to install Yarn package manager for Node.js, which have multiple benefits over npm.