How To Install Node.js on Ubuntu 16.04

How To Install Node.js on Ubuntu 16.04

We’ll guide you, how to install Node.js on Ubuntu 16.04. Node.js is an open source JavaScript runtime built on Chrome’s V8 JavaScript engine and can be used to build different types of server-side applications. Node.js runs on most operating systems, including Linux, OSX and Windows. In this tutorial, we will guide you through the steps of installing Node.js on an Ubuntu 16.04 VPS. The installation of Node.js on Ubuntu 16.04, can be done using several different methods:

  • APT: the default Ubuntu package manager
  • PPA: Personal Package Manager
  • NVM: Node Version Manager

Install Node.js on Ubuntu 16.04

1. Update the system

Login to your Ubuntu 16.04 VPS via SSH as user root

ssh root@IP_Address -p Port_Number

and make sure all installed packages are updated to the latest available version

apt-get update && apt-get upgrade

2. Installing Node.js on Ubuntu 16.04 with APT

Node.js can be easily installed from the official Ubuntu 16.04 repositories using the APT package manager

apt-get install nodejs

To check which version of Node.js is installed on your server run the following command

nodejs -v
v4.2.6

In our case, it is version 4.2.6

You should also install NPM to easily manage different Node.js packages

apt-get install npm

Once installed, you can check the version

npm -v
3.5.2

3. Installing Node.js on Ubuntu 16.04 with PPA

If you need a newer version of Node.js than the one available in the official Ubuntu repositories, you can add a PPA (Personal Package Archive) and install Node.js from this archive.

Install curl if it is not already installed

apt-get install curl

And download the installation script for the version of Node.js you can to install. In this tutorial, we will install Node.js version 8.x.x

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -

This will add the PPA and update the package cache. To install Node.js run the following command

apt-get install nodejs

check the installed version

nodejs -v
v8.9.4

Finally, install the build-essential package to be able to use some npm packages

apt-get install build-essential

4. Installing Node.js on Ubuntu 16.04 with NVM

Instead of using apt, you can also install Node.js with NVM (Node.js Version Manager). With this tool, you can install multiple different version of Node.js on your Ubuntu 16.04 VPS.

Install some dependencies

apt-get install build-essential libssl-dev

Download NVM’s installation script

curl -sL https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh -o install.sh

and execute it

bash install.sh

Everything will be installed in a ‘.nvm’ directory inside your user’s home directory and add some necessary lines to the ‘.profile’ file.

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer
NVME 2 VPS

Now just $43 .99
/mo

GET YOUR VPS

Source the .profile file for the changes to take effect

source ~/.profile

Now, run the following command to check all Node.js versions available for install

nvm ls-remote

v8.9.0 (LTS: Carbon)
v8.9.1 (LTS: Carbon)
v8.9.2 (LTS: Carbon)
v8.9.3 (LTS: Carbon)
v8.9.4 (Latest LTS: Carbon)
v9.0.0
v9.1.0
v9.2.0
v9.2.1
v9.3.0
v9.4.0
v9.5.0

To install a specific version use ‘nvm install’ and enter the appropriate version. For example

nvm install v9.5.0

5. List all installed Versions of Node.js on Ubuntu 16.04

If you have multiple versions of Node.js installed on your server, you can list them with the following command

nvm ls

How To Install Node.js on Ubuntu 16.04Of course, you don’t have to Install Node.js on Ubuntu 16.04, if you use one of our Blazing-Fast SSD VPS Hosting services, in which case you can simply ask our expert Linux admins to install Node.js on Ubuntu 16.0, for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post on how to Install Node.js on Ubuntu 16.04, and create your first Express application, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

New guide available here: How to install Node.js and npm on Ubuntu 20.04.

2 thoughts on “How To Install Node.js on Ubuntu 16.04”

  1. Good tutorial!! In the step 3 (Install Node.js on Ubuntu 16.04 with PPA) apt-get istall curl instead apt-get install curl

    Reply

Leave a Comment