How to Install The Latest LTS Release of Node.js in Ubuntu

Tutorial Jan 21, 2021

Node.js is an open-source, cross-platform JavaScript run-time environment for running JavaScript code outside of a web browser.

This is a tutorial on how to install the latest LTS (Long Term Support) release of Node.js in Ubuntu. So, essentially, this guide should apply to any Ubuntu-based distribution, like Xubuntu, Kubuntu, Ubuntu MATE, Linux Mint, Elementary OS, Pop!_OS etc.

As Ubuntu users, we are blessed with the apt command to install programs with a single line of command. Unfortunately, not all programs that the default Ubuntu repositories offer are up to date. At the time of writing this, the version of Node.js offered by the default repositories is v10.19.0

The following instructions were tested on a fresh install on Ubuntu 20.04.1.

INSTALLATION

First, we should run apt update and install curl.

sudo apt update
sudo apt install -y curl

We will be installing the latest LTS version of Node.js using NodeSource's PPA (Personal Package Archive). And for that, we need to install their PPA first. Running the following command will download and run the official script offered by NodeSource to install the required PPA.

curl -sL https://deb.nodesource.com/setup_lts.x | sudo -E bash -

Now, we can install nodejs using apt.

sudo apt install -y nodejs

When the installation process completes, we can confirm the version of Node.js by running the following command.

node -v
v14.15.4

And that is all! We now have the latest LTS release of Node.js.

How to Change The Global Modules Directory of Node.js in Ubuntu

Tags

Lime

Simple, like quantum physics.

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.