Upgrade to Node.js 10.x or 11.x on Ubuntu 18.10

The latest and greatest, albeit not a long-term support release, from Canonical
is here!

Ubuntu 18.10, Cosmic Cuttlefish, was released this month and shipped with the
current LTS version of Node.js, version 8. Actually, it’s a minor revision
behind at the moment with 8.11.x being what’s available.

Not that there’s anything wrong with 8.x series of Node.js, but with the current
speed of interation that the Node.js team is at, it’s already a dinosaur.

Version 10.x has been available for 6 months and will become the the LTS version
of Node.js on the 30th of this month, and the 11.x series, which won’t ever
become an LTS release, is already making waves.

Fear not! If you want to start living in the future with the latest Node.js
on your shiny new Ubuntu install, you can do so with minimal effort.

First, make sure you have curl installed, or whatever your favorite network
transfer app is, adjust accordingly:

sudo apt-get install curl

With curl ready to rock, we will need to pull down and execute the installer
script provided by NodeSource. Not much to it:

# For the soon to be LTS release, 10.x
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -

# For the bleeding edge, 11.x
curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash -

It’s going to be a minute while the repository is setup and it will take care of
running apt-get update for you as well.

Once it’s done it’s thing, you can go ahead and install Node.js:

sudo apt-get install nodejs

If you happened to have had Node.js already installed, it will be upgraded for
you to whichever version you had chosen for the installed.

To verify that things went according to plan, you can check the currently
installed version of Node.js:

node --version

Assuming that reported the version of Node.js you were expecting, you should be
be good to go!

Josh Sherman - The Man, The Myth, The Avatar

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.

If you found this article helpful, please consider buying me a coffee.