How to install Node.js 16 on Ubuntu 20.04 LTS

Josh Sherman
3 min read
Servers / Serverless Node.js Debian / Ubuntu

Ubuntu tends to drop a new version of their April release shortly after a new version of Node.js drops. Every other year, this Ubuntu release is a long-term support release, which has a longer shelf life in terms of support and maintenance compared to their interim releases.

True to form of Debian and Debian-based distros striving for stability, Ubuntu doesn’t include the latest and greatest version of Node.js with their LTS releases. In fact, depending on the year, you get the current LTS version of Node.js or something even older.

With Ubuntu 20.04 LTS, you Node.js 10.x, which at this point, is quite behind as Node.js 16.x is available and 10.x will be leaving maintenance mode this month. Node.js 16.x won’t become the LTS release until later this year, but it’s still considered stable and will inevitably become the LTS release, so there’s no reason not to upgrade!

To get started, I always like to make sure my Ubuntu installation is fully up to date:

sudo apt update
sudo apt upgrade

Don’t forget to reboot if you had any updates to the Linux Kernel.

With things all up to date, let’s make sure we have curl installed, as we’ll be using that to download the installation script from NodeSource (which provides binary packages for Ubuntu, Debian and a bunch of their derivatives):

sudo apt install -y curl

Obviously if you know you already have curl installed, you don’t need to run this. Once we have curl in the mix, we can download and run the setup script:

curl -fsSL | sudo -E bash -

That script will run, gets thing added to your apt sources, and will even run another apt update to make sure you’re ready to go.

Once that’s done running, you will need to install or upgrade the current version of Node.js you have installed:

sudo apt install -y nodejs

At this point, you should be all set. Just to be certain, you can run node to figure out what version you’re currently running:

$ node --version

A little note, because it never fails that somebody brings up that you could nvm to accomplish this. While you certainly COULD use nvm, and that may be your preferred method, it’s not mine, for a number of reasons.

First, nvm needed to be sourced in your shell profile, which can slow your prompt down when creating new sessions. I’ve been able to speed things up by lazy loading it, but that wasn’t my biggest issue with using nvm.

My biggest concern with using nvm on a server is that it creates an additional way to install / update packages. By using this method, you add Node.js into your system’s existing package manager, apt and you can easily upgrade nodejs along with your other system packages.

This makes it the clear choice for me, as it’s one less thing for me to have to think about when maintaining a server.

Join the Conversation

Good stuff? Want more?

Weekly emails about technology, development, and sometimes sauerkraut.

100% Fresh, Grade A Content, Never Spam.

About Josh

Husband. Father. Pug dad. Musician. Founder of Holiday API, Head of Engineering and Emoji Specialist at Mailshake, and author of the best damn Lorem Ipsum Library for PHP.

Currently Reading

Parasie Eve

Previous Reads

Buy Me a Coffee Become a Sponsor

Related Articles