How to install Node.js on CentOS/cPanel

Run as root on RHEL, CentOS or Fedora:

curl -sL | bash -

Then install, as root:

yum install -y nodejs

The -y flag will automatically answer “yes” to every confirmation question, so leave it out if you want to be able to say no to something.

Optional: install build tools

To compile and install native addons from npm you may also need to install build tools:

yum install gcc-c++ make


yum groupinstall 'Development Tools'

This command will pull a “Development Tools” group with the applications needed to compile node.js.

To test an installation, run:

curl -sL | bash -

If you get an error saying ‘-bash: npm: command not found’, try the alternative method of installing Node.js by compiling from source.

Alternative: Compiling from Source

su - 
# install dev tools
yum install gcc-c++ openssl-devel
cd /usr/local/src
# fetch latest node.js tarball
# extract tarball
tar zxvf node-latest.tar.gz
# (cd into extracted folder: ex "cd node-v0.10.3")
cd node-v*
# execute the configure script
# make is probably the longest task here, it will take a while
# make it available system wide
make install

Note that this requires Python 2.6+ to use ./configure above. Otherwise, you’ll get an error like this:

File "./configure", line 452
    fpu = 'vfpv3' if armv7 else 'vfpv2'
SyntaxError: invalid syntax

To avoid that, run python2.7 ./configure