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.

Share
Published by
Chandan Kumar

Recent Posts

How SaaS Business can use a Knowledge base to Delight Customers ?

Delivering customer satisfaction in a SaaS business is priority 1,2 and 3, at least that’s…

1 day ago

How to Implement Push Notifications for more Customer Engagement?

We all deal with push notifications on a daily basis. Apps and websites use them…

2 days ago

9 Good Antivirus for Small to Medium Business

As each year is passing by, the need for a good antivirus keeps on increasing.…

2 days ago

6 Business Email Security Solutions to Protect from Spam and Phishing Attacks

Emails are an inherent part of your company’s business process, whether you want to interact…

3 days ago

7 Best Managed VPS Hosting for Small to Medium Business

There comes a time in every successful business when you have to upgrade your resources,…

3 days ago

5 Best Cloud-based VAPT for Small to Medium Business Sites

The e-commerce landscape has been dramatically boosted in recent times by advances in Internet technologies…

5 days ago