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.
You must have shell access to your Ubuntu 20.04 system with sudo privileged account. Login to your system and open a terminal.
Choose one the the below options to install Node.js on Ubuntu 20.04 system. Option 1 is used to install Nodejs with NVM on Ubuntu and option 2 will show your instruction to install Node.js on Ubuntu 20.04 via PPA.
Option 1 – Install Node.js via NVM on Ubuntu 20.04
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
Now, load the nvm environment 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.18.4
You can run above command with different-2 versions to install any number of Node.js on Ubuntu 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.18.4
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 on Ubuntu 20.04 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.18.4
You have learned to install Node.js on Ubuntu 20.04. In this tutorial, you found two methods for installing node.js on Ubuntu. Next you may need to install Yarn package manager for Node.js, which have multiple benefits over npm.