Sudo install nodejs

Install Node.js on your system by running the following command: sudo apt-get install -y nodejs Once the installation is finished, check the installed Node.js version using the .

How to install Node.js 18 on Ubuntu 20.04 LTS

It’s that time of year again, for not just a new version of Node.js, but for a
new version of Ubuntu as well! Sadly though, my preferred method of installing
Node.js on Ubuntu isn’t quite ready for Ubuntu 22.04 LTS.

That’s okay though, I don’t like to upgrade to a new version of just about
anything until it’s had enough time to percolate and have the early release
bugs sorted out.

So with that being said, today we’re going to install Node.js 18, which is the
new “current” version, on ol’ reliable of the past 2 years, Ubuntu 20.04 LTS.

Keep in mind that Ubuntu 22.04 LTS is shipping with Node.js 12, which is to be
expected due to Debian / Debian-based distros focus on stability. If you are
trying to use Ubuntu 22.04 LTS, your best bet is to give a spin if you are
in need of the latest version of Node.js.

I’ve mentioned this previously, is more than sufficient to getting the
latest version (or different versions) of Node.js running on your machine. I
personally avoid this in production environments, as I much prefer relying on
the system’s package manager to do all of my upgrades, instead of having to
remember multiple package / version managers.

This is the same logic that keeps me from compiling software if at all possible.

System updates and dependency installation

All that being said, I always like to start by making sure my system is 100% up
to date (rebooting if necessary):

Zsh

Also, if you don’t already have installed, it’s a good time to do that as
well, since we’ll be using that to download the installation script from
NodeSource:

Zsh

Installing Node.js 18 on Ubuntu

With our system up to date and our dependencies in check, let’s grab the setup
script for Node.js 18 and give it a spin:

Zsh

The provided script will add in some new sources and even runs to ensure we have our cache primed and ready to rock!

Once the script is done running, you can install or upgrade to Node.js 18:

Zsh

And once that’s finished running, we can check that we are in fact running the
latest and greatest version of Node.js:

Zsh

If you ARE NOT running the latest version of Node.js at this point, double check
the output of the previous commands, as more than likely one of them spit out an error that may need to be addressed.

Explore More Articles

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!

Debian / UbuntuNode.js