How To Install Node.js On Ubuntu 16.04


What Is Node.js?

Node.js is a software platform for Javascript that allows code for both the back end server and the front end client to be written in the same language. It is an excellent tool for putting together web applications, especially those that deal with real time data.

In this guide we will show you how to get a basic setup of Node.js running on your Ubuntu 16.04 server.

Installing Node.js

There are a few different ways to install Node.js, each comes with their own advantages and disadvantages.

Default Apt

The default Ubuntu repos do contain a version of Node.js. It is never the latest version but is usually known to be quite stable. Often times this is used to quick experiment with the language.

To install it simply run:

apt-get update
apt-get install nodejs

This will install Node.js, however we still need to install the package manager (NPM) so that 3rd party modules can be installed.

You can install it with:

apt-get install npm

After you have done both of these sections of commands it will be installed on your system.


If you want to install a newer version of Node.js while still being able to use apt, you can use a PPA (personal package archive). In this case we will be using Nodesource’s. They have newer version available than the default Ubuntu repos.

First we have to download their setup script.

curl -sL -o

Then, after verifying the script is the one you want, run the command below to execute it.


Once the script finishes executing you can install Node.js just as you would for any other package normally.

apt-get install nodejs

In this version you do not have to install npm separately, but you still need to have the build tools available in case npm needs to compile packages. Run the command:

apt-get install build-essential

This will make sure the required software is installed.


Instead of using a standard install tool like apt, you can also choose to use NVM. NVM stands for Node.js Version Manager. The largest benefit of using NVM, is that you can install multiple version of Node.js at the same time. You can then easily switch between them as needed and target multiple different versions with your applications.

Before we install NVM, we need to install a few prerequisites.

apt-get update
apt-get install build-essential libssl-dev

Once those are installed you need to download the setup script for NVM. Typically you can grab this from their github page. Though at the time of this writing the newest version is in the command below:

wget -qO-

Verify that the script is indeed the one you want and then run:


to begin the install of NVM. Once it finishes you will need to reload your profile to have your changes take effect without logging back in to your server again. Run the command:

source ~/.profile

The nvm command will now be available to you. To see what version are available for installation you can run:

nvm ls-remote


To install a specific version run choose one from the list and run:

nvm install 6.0.0

To see what version is currently in use you can run

node -v

To switch between node version run the command (in this case switch to version 6.0.0)

nvm use 6.0.0

In a similar command to what you ran to see what version were available to install. You can run this to see what versions you have installed locally.

nvm ls

To make a specific version default run the command

nvm alias default 6.0.0


Once you have followed one of the versions above you will have successfully installed Node.js on your Ubuntu 16.04 server. Personally I would recommend using NVM since it allows much more long term flexibility due to the multiple versions and version switching.

CC BY 4.0 This work is licensed under a Creative Commons Attribution 4.0 International License.

Alex Wacker has written 16 articles

I am the founder and owner of Subnet Labs LLC. Impact VPS is one of our VPS brands. Linux, virtualizaton and the internet amaze me and I enjoy learning new things every day about them.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>