How to install Node.js on Ubuntu Linux 16.04 LTS server

How do I install Node.js (“Javascript for server-side programming”) on an Ubuntu Linux 16.04 LTS server using command line only option?

Node.js is an open source program to write server application in JavaScript. It is a built on Chrome’s JavaScript runtime. Back in the old days, JavaScript was used primarily for client-side scripting. Node.js allows JavaScript to be used for server-side scripting and output dynamic web page for users. This tutorial shows you how to install Node.js on an Ubuntu Linux 16.04 LTS server.

Method #1: Install the bundled distro specif Node.js version 4.2.6

Type the following apt command or apt-get command to install both npm and nodejs:
$ sudo apt install nodejs
$ sudo apt-get install nodejs npm
Sample outputs:

Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
The following NEW packages will be installed:
  libuv1 nodejs
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 3218 kB of archives.
After this operation, 13.4 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 xenial/universe amd64 libuv1 amd64 1.8.0-1 [57.4 kB]
Get:2 xenial-updates/universe amd64 nodejs amd64 4.2.6~dfsg-1ubuntu4.1 [3161 kB]
Fetched 3218 kB in 6s (519 kB/s)                                                                                                                                            
Selecting previously unselected package libuv1:amd64.
(Reading database ... 32088 files and directories currently installed.)
Preparing to unpack .../libuv1_1.8.0-1_amd64.deb ...
Unpacking libuv1:amd64 (1.8.0-1) ...
Selecting previously unselected package nodejs.
Preparing to unpack .../nodejs_4.2.6~dfsg-1ubuntu4.1_amd64.deb ...
Unpacking nodejs (4.2.6~dfsg-1ubuntu4.1) ...
Processing triggers for libc-bin (2.23-0ubuntu7) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up libuv1:amd64 (1.8.0-1) ...
Setting up nodejs (4.2.6~dfsg-1ubuntu4.1) ...
update-alternatives: using /usr/bin/nodejs to provide /usr/bin/js (js) in auto mode
Processing triggers for libc-bin (2.23-0ubuntu7) ...

Verify version:
$ nodejs --version
$ npm --version

Method #2: Install the latest version of Node.js version 6.x or 7.x

The syntax is as follows to install Node.js version 6.x (stable LTS and recommended for production usage):
$ curl -sL | sudo -E bash -
$ sudo apt-get install -y nodejs build-essential

Sample outputs:

Fig.01: Installing LTS version of Node.js on an Ubuntu 16.04 server

The syntax is as follows to install Node.js version 7.x (current/latest and recommended for testing purpose):
$ curl -sL | sudo -E bash -
$ sudo apt-get install -y nodejs build-essential

Verify it

Type the following commands:
$ nodejs --version
$ npm --version

And there you have it, Node.js installed and working. You can start writing apps now. See the official website for more information.

🐧 Please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
0 comments… add one

Leave a Reply

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

Use HTML <pre>...</pre> for code samples. Problem posting comment? Email me @