Node.js is a cross-platform JavaScript run-time setting that enables server-side execution of JavaScript code. Node.js is especially used on the back-end, however additionally it is well-liked as a full-stack and front-end answer.

This tutorial walks you thru the steps to put in Node.js and npm on a CentOS 7 machine.

In case you want Node.js just for deploying Node.js functions then the only choice is to put in the Node.js packages utilizing yum from the NodeSource repository

Installing Node.js and npm on CentOS 7

1. Add NodeSource yum repository

The current LTS version of Node.js is version 10.x. If you want to install version 8 just change setup_10.x with setup_8.x in the command below.

Run the following curl command to add the NodeSource yum repository to your system:

curl -sL | sudo bash -

2. Install Node.js and npm

Once the NodeSource repository is enabled, install Node.js and npm by typing:

sudo yum install nodejs

When prompted to import the repository GPG key, type y, and press Enter.

3. Verify the Node.js and npm Installation

To check that the installation was successful, run the following commands which will print the Node.js and npm versions.

Print Node.js version:

node --version

Print npm version:

npm --version