Categories: Sysadmin

How to Install Node.js 11 on Ubuntu, CentOS?

Procedure to install Node.js 11.x on Ubuntu 16.x/18.x, CentOS 7.x through binary distribution or from the source.

Node.js popularity is growing faster than ever. If you recently started learning Nodejs development, then one of the first things you need to do is to install them.

Technically, there are multiple ways to get things installed but following the easy and right process will make life much easier.

The following, I’ve tested on DigitalOcean server. Let’s get it started.

Ubuntu 16.x or 18.x

The latest version of Nodejs is not available through the default repository. But not to worry, you can use NodeSource distribution as the following.

  • Log in to the server as root
  • Execute the following
curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash -

The above will download and install the NodeSource Node.js repository. At the end of the above output, you should see something like this.

Reading package lists... Done

## Run `sudo apt-get install -y nodejs` to install Node.js 11.x and npm
## You may also need development tools to build native addons:
     sudo apt-get install gcc g++ make
## To install the Yarn package manager, run:
     curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
     echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
     sudo apt-get update && sudo apt-get install yarn
  • Next, you will have to install the nodejs with the following command.
apt-get install -y nodejs

It will take a few seconds and once done; you should be able to verify the version.

root@geekflarelab:~# nodejs -v
v11.7.0
root@geekflarelab:~#

And, as you can see, it has installed 11.7.0 version.

CentOS/RHEL 7.x

First, you need to install the NodeSource repository with the following command.

curl -sL https://rpm.nodesource.com/setup_11.x | bash -

And then, install the Nodejs as below.

yum install -y nodejs

It will take a few seconds, and at the end, you should see something like below.

Running transaction
  Installing : 2:nodejs-11.7.0-1nodesource.x86_64                                                                                                       1/1 
  Verifying  : 2:nodejs-11.7.0-1nodesource.x86_64                                                                                                       1/1 

Installed:
  nodejs.x86_64 2:11.7.0-1nodesource                                                                                                                        

Complete!
[root@geekflarelab ~]#

This means the Node.js is installed and can be verified with -v syntax.

[root@geekflarelab ~]# node -v
v11.7.0
[root@geekflarelab ~]#

The above instruction should also work for Fedora 29 or later.

Installing from Source Code

What if you are in a DMZ environment where you can’t connect to the Internet? You still can install by building the source code. The procedure is not as easy as above through binary distribution but doable.

  • Login to Ubuntu or CentOS server
  • Download the latest or the one you want from here using wget. I am trying the latest one.
wget https://nodejs.org/dist/v11.7.0/node-v11.7.0.tar.gz
  • Extract the downloaded file with tar command
tar -xvf node-v11.7.0.tar.gz
  • You should see a new folder created in the present working directory
drwxr-xr-x 9  502  501     4096 Jan 17 21:27 node-v11.7.0
  • Go to the newly created folder
cd node-v11.7.0/

And, its time to build the Node.js from source now.

But, before you proceed, ensure you have the pre-requisites installed.

If using Ubuntu then install the pre-requisites with below

apt-get update
apt-get install gcc g++ clang make

and for CentOS

yum update
yum install gcc clang gcc-c++
  • Let’s built it now
./configure
  • Ensure no error and then next
make
make install

It will take some time to build and once done; you can verify the installed version by executing below.

root@geekflarelab:~# node --version
v11.7.0
root@geekflarelab:~#

You see, installing Nodejs is easy. Nex, you may want to learn and understand Nodejs.

Chandan Kumar

Since founded Geekflare, I've helped millions of professional through my articles and tools. Let's connect on Twitter or LinkedIn.

Recent Posts

What is URL Blacklist and How to Fix It?

Your website is the face of your business. It not only serves as a medium…

April 7, 2020

An Introduction to ☁️ Cloud Service Models – PaaS, SaaS, IaaS, FaaS and More…

There are many short names used in Cloud Service Models, and sometimes it may be…

April 5, 2020

Top 5 Third-party Data Connectors for Google Data Studio

As a dashboard and reporting tool for the masses, Google Data Studio is consistently gaining…

April 2, 2020

25 Companies Offering FREE Services During Covid-19

The COVID-19 outbreak has disrupted the entire world, including millions of businesses. Many businesses have…

April 1, 2020

9 Best Video Marketing Tools to Boost Sales and Brand Awareness

Every business should make video marketing an integral part of its strategy to stay on…

March 30, 2020

15 Impressive Online Video Maker for Your Business

You’re leaving a lot of money on the table if you don’t create videos for…

March 28, 2020