In this guide, we will show you three different ways of getting Node.js installed on an Ubuntu 20.04 server:
aptto install the
nodejspackage from Ubuntu’s default software repository
aptwith an alternate PPA software repository to install specific versions of the
nvm, the Node Version Manager, and using it to install and manage multiple versions of Node.js
For many users, using
apt with the default, the repo will be sufficient. If you need specific newer (or legacy) versions of Node, you should use the PPA repository.
This guide assumes that you are using Ubuntu 20.04. Before you begin, you should have a non-root user account with
sudo privileges set up on your system.
If you are actively developing Node applications and need to switch between
node versions frequently, choose the
To get this version, you can use the
apt package manager. Refresh your local package index first by typing:
sudo apt update
Then install Node.js:
sudo apt install nodejs
Check that the install was successful by querying
node for its version number:
node -v Output v10.19.0
If the package in the repositories suits your needs, this is all you need to do to get set up with Node.js. In most cases, you’ll also want to also install
npm, the Node.js package manager. You can do this by installing the
npm package with
sudo apt install npm
This will allow you to install modules and packages to use with Node.js.
There are quite a few ways to get up and running with Node.js on your Ubuntu 20.04 server. Your circumstances will dictate which of the above methods is best for your needs. While using the packaged version in Ubuntu’s repository is the easiest method, using
nvm or a NodeSource PPA offers additional flexibility.