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!
Updating your system and installing necessary software
To get started, I always like to make sure my Ubuntu installation is fully up to
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):
Setting up and installing Node.js 16 on Ubuntu
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:
That script will run, gets thing added to your
apt sources, and will even run
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:
At this point, you should be all set. Just to be certain, you can run
figure out what version you’re currently running:
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.
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
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.
Explore More Articles
- Speed up your shell prompt when using Node Version Manager
- How to install Node.js 21 on Ubuntu
- How to install Node.js 20 on Ubuntu 20.04 LTS
- How to install Node.js 18 on Ubuntu 20.04 LTS
Looking for an Ubuntu host?
Check out DigitalOcean, with $200 of free credit to spend over 2 months, you can explore Ubuntu on their Droplets and all of their other managed services!