Instructions for installing Node.js and NPM on Centos 7

Tutorials 0 lượt xem

Node.js is a Javascript runtime built on Chrome’s V8 Javascript engine. Node.js allows you to build many types of server-side applications quickly and easily.

With Node.js you can use your Javascript programming skills on a server environment. While NPM is the largest open source ecosystem in the world.

In today’s post we will show you how to install Node.js and npm on CentOS 7. Installation is pretty easy. You just follow the instructions as below.

Step 1: Prepare

You need to prepare the following:

  • A brand new Linux server with CentOS 7 installed. This tutorial I made on Digital Ocean ‘s VPS (See discount code HERE ). You can refer to other VPS providers here.
  • Connect to the server using an SSH Client like MobaXterm . Login with root user.

Step 2: Update the system and install the necessary software:

Step 3: Install Node.js and npm from NodeSource repository

We will install the Node.js 6 LTS from the NodeSource repository. Because NodeSource repository depends on EPEL repository. So you need to install the EPEL repository with the following command:

Then run the following command to install the NodeSource repository

Once the NodeSource is ready, you install Node.js and NPM with the following command:

After successful installation, you can check the version of Node.js with the command:

You will get the following output: v6.11.4

To check if npm install was successful, use the following command:

You will get the following result: 3.10.10

install node js on centos 1

Step 4: Check the settings again

If you want to know if Node.js is working OK or not, let’s create a test file:

Then you add the following line of code: (remember to enter your ip address)

Start the node web server with the following command:

You will get the result like below

install node js on centos 2

Open your browser and go to http://your_ip_address:3000 , you will see “Hello World”.

That is all. You have learned how to install Node.js and npm on Centos 7.

Bài viết liên quan