Notes

How to install Node.js on CentOS/cPanel

Edit on GitHub

Linux
2 minutes

Run as root on RHEL, CentOS or Fedora:

1curl -sL https://rpm.nodesource.com/setup | bash -

Then install, as root:

1yum 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:

1yum install gcc-c++ make

OR

1yum groupinstall 'Development Tools'

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

To test an installation, run:

1curl -sL https://deb.nodesource.com/test | 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

 1su - 
 2# install dev tools
 3yum install gcc-c++ openssl-devel
 4cd /usr/local/src
 5# fetch latest node.js tarball
 6wget http://nodejs.org/dist/node-latest.tar.gz
 7# extract tarball
 8tar zxvf node-latest.tar.gz
 9# (cd into extracted folder: ex "cd node-v0.10.3")
10cd node-v*
11# execute the configure script
12./configure
13# make is probably the longest task here, it will take a while
14make
15# make it available system wide
16make install

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

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

To avoid that, run python2.7 ./configure