Node Version Manager is a helpful utility to install and manage multiple node.js versions 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 users, you need to log in to that user and install the required node.js version there.

Prerequisites

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 of the below options to install Node.js on the Ubuntu 20.04 LTS 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.

Method 1 – Install Node.js via NVM on Ubuntu 20.04

NVM provides a shell script for the installation on the Linux system. So, execute the installer script with the below commands. This will install the nvm command on your system. Now, load the nvm environment in the current shell with the below command. NVM is successfully installed on your system. Now you can install any node.js version with the help of NVM. You can run the above command with different-2 versions to install any number of Node.js on the Ubuntu system. For example you can use nvm install 17 or nvm install 12.18 etc. The systems have multiple node.js versions installed, can use the below command to set any installed node.js version as an active version. 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.

Method 2 – Install Node.js with Official Node PPA

The official team provides a repository for the Node.js installation on the Ubuntu system. But it has limitations to installing a single version at a time. You can use multiple versions on a single system similar to nvm. Run the below commands to enable PPA to your system. Once you add the repository, install Node.js by executing the following command. Once you complete the installation, run the below command to view the current Node.js version.

Conclusion

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.