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 the 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

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

Next, you will have to install the nodejs with the following command.

It will take a few seconds and once done; you should be able to verify the version. And, as you can see, it has installed 11.7.0 version.

CentOS/RHEL 7.x or 8.x

First, you need to install the NodeSource repository with the following command. Install Nodejs 11.x Install Nodejs 12.x Install Nodejs 14.x And then, install the Nodejs as below. If you are using CentOS 8.x then you may also try DNF. It will take a few seconds, and in the end, you should see something like below. This means the Node.js is installed and can be verified with -v syntax. 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 it 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.

Extract the downloaded file with tar command

You should see a new folder created in the present working directory

Go to the newly created folder

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 and for CentOS

Let’s built it now

Ensure no error and then next

It will take some time to build and once done; you can verify the installed version by executing below. You see, installing Nodejs is easy. Next, you may want to explore the Nodejs framework to become a professional programmer.

How to Install Node js on Ubuntu  CentOS  - 96How to Install Node js on Ubuntu  CentOS  - 16How to Install Node js on Ubuntu  CentOS  - 70How to Install Node js on Ubuntu  CentOS  - 23How to Install Node js on Ubuntu  CentOS  - 52How to Install Node js on Ubuntu  CentOS  - 53How to Install Node js on Ubuntu  CentOS  - 84How to Install Node js on Ubuntu  CentOS  - 33How to Install Node js on Ubuntu  CentOS  - 37How to Install Node js on Ubuntu  CentOS  - 4How to Install Node js on Ubuntu  CentOS  - 75How to Install Node js on Ubuntu  CentOS  - 29How to Install Node js on Ubuntu  CentOS  - 71How to Install Node js on Ubuntu  CentOS  - 28How to Install Node js on Ubuntu  CentOS  - 78How to Install Node js on Ubuntu  CentOS  - 13How to Install Node js on Ubuntu  CentOS  - 7How to Install Node js on Ubuntu  CentOS  - 35How to Install Node js on Ubuntu  CentOS  - 21How to Install Node js on Ubuntu  CentOS  - 25How to Install Node js on Ubuntu  CentOS  - 61How to Install Node js on Ubuntu  CentOS  - 88How to Install Node js on Ubuntu  CentOS  - 10