[2 min installs] Node.js on Ubuntu

Better Stack Team
Updated on August 29, 2022

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
Copied!

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
Copied!

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
Copied!

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
Copied!
Check Uptime, Ping, Ports, SSL and more.
Get Slack, SMS and phone incident alerts.
Easy on-call duty scheduling.
Create free status page on your domain.
Got an article suggestion? Let us know
Next article
[2 min installs] Python on Ubuntu
Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.