How to install Node.js v14.x on Ubuntu 17.04

Even though you should be considering upgrading this interim release of Ubuntu,
you can still leverage the latest version of Node.js to squeak just a bit more
life out of it. Follow these quick and easy steps to install Node Version
Manager and Node.js v14.x on your EOL Ubuntu 17.04 system.<h2 id=”getting-started”>Getting started</h2>

Before we can install Node Version Manager (which will then be used to install
Node.js) we need to ensure that we have curl installed so that we can easily
download the install script we need to run.

If you’re running inside of a Docker container, you should start by updating
your system, else you’ll run into errors about how the curl package cannot be
found:

su -c 'apt update'

Once things are up to date, install curl:

su -c 'apt install -y curl'

Installing Node Version Manager

To get things running quickly and easily, we will download the installation
script for Node Version Manager from the package’s repository and run it:

su -c 'curl -sL https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash -'

Once Node Version Manager is installed, the script will log some lines that will
need to be added to your shell profile (.bashrc, .zshrc, et cetera):

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

You will absolutely have to run those commands if you want to use nvm from the
command line. If you copy and paste them back in the terminal, and close the
terminal out, you won’t have nvm available until you run them again.

Installing Node.js v14.x

With Node Version Manager installed and the aforementioned shell profile
commands executed (making nvm available) we can go ahead and install Node.js
v14.x:

nvm install 14

Without a minor version, Node Version Manage will install the latest versions of
the v14.x series. If you’d like, you can specify the full version number to
explicitly install that specific version.

To check that Node.js is the proper version, simply ask Node.js to spit out it’s
version number:

node --version # v14.0.0

Setting Node.js v14.x as your default

If this is your first time using Node Version Manager, then Node.js v14.x will
automatically be flagged as your default version.

If this isn’t your first rodeo, you probably have some other version of Node.js
previously installed that is potentially your default.

To switch Node.js v14.x to be your default Node.js version, just alias it with
the nvm command:

nvm alias default 14
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.