Node.js is an open-source, cross-platform JavaScript run-time environment that executes JavaScript code outside of a browser. Node.js lets developers use JavaScript to write command-line tools and for server-side scripting—running scripts server-side to produce dynamic web page content before the page is sent to the user's web browser.

NPM is a package manager for the JavaScript programming language. It is the default package manager for the JavaScript runtime environment Node.js.

In this guide, we will explain how to install NodeJS & NPM on CentOS 7 server.

Deploying your cloud server
If you have not already registered with Cloudwafer, you should begin by getting signed up. Take a moment to create an account after which you can easily deploy your own cloud servers.

Once you have signed up, log into your Cloudwafer Client Area and deploy your Cloudwafer cloud server.

Updating System Packages on CentOS
It is always recommended that you update the system to the latest packages before beginning any major installations. This is done with the command below:

sudo yum update

You can also view our guide on Installing NodeJS & NPM on Ubuntu 16.04/18.04

Step 1: Install Build Tools and Add Node.js Yum Repository
We will add the most recent packages of Node.js which are available on the Yum repository. First, update your system and install some dependencies.

sudo yum install -y gcc-c++ make
sudo curl -sL https://rpm.nodesource.com/setup_12.x | sudo -E bash -

To check the latest release, visit the Node.js Releases page

Step 2: Install NodeJS Issue the command below to install NodeJS:

sudo yum install -y nodejs

After successfully installing, you can confirm versions of nodejs with the command below:

node --version
npm --version

Step 3: Install Yarn package manager
This is optional but to install the Yarn package manager, issue the command below:

curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo

sudo yum install yarn

Verify installation with the command below:

yarn --version

To learn more about NodeJS, you can read the official documentation for more information.