How to install Node.js on CentOS

Node.js is a javascript platform that also includes the Node package manager (NPM). The EPEL installation is the simplest way to install and ensure that it's updated, but you may not want to use that if you prefer to install from source.

Install from EPEL Repository

Installing through EPEL is preferable in most cases as it will make it easy to remove or update as needed.

Use SSH to log into your server as root.

Install the EPEL repository

yum install epel-release

Once EPEL is installed, you can install Node.js easily

yum install nodejs

Installing Node.js from source

Use SSH to log into your server as root.

Run the following to make sure that you have the latest version of gcc, which you will need to compile it.

yum install gcc gcc-c++

Run the following commands to download the source file and compile it:

cd ~
tar xzvf node-v* && cd node-v*
make install

Check the installation

After you've installed Node.js using one of the methods above, make sure to check the installation to be sure that it was installed correctly.

Run the following command:

node --version

And you should see something like