Here is how to install Node.js and npm package manager on Ubuntu 20.04 in under 2 minutes:
Step 1 — Update package index
Before the actual installation process, update the package index:
$ sudo apt update
apt update downloads the package lists from the repositories and updates them to get information on the newest versions of packages and their dependencies. It will do this for all repositories and PPAs.
Step 2 — Install Node.js
Default Ubuntu repositories include Node.js (v10.19 for Ubuntu 20.04), so we can install Node.js via apt:
$ sudo apt install -y nodejs
Step 3 — Install NPM
Usually, Node.js comes with npm, however, if you install it using Ubuntu default repositories, you will be required to install npm manually:
$ sudo apt install npm
That’s it
Node.js and npm package manager is now installed on your system. To see if everything worked as planned type the following command:
node -v && npm -v
Output:
v16.13.2
8.5.0