Install Node.js from source on CentOS

Before we start, it would be a good idea to update software repository to
the latest version:

1
yum -y update

Steps:

Install Development Tools. Development Tools is a group of tools
for compiling software from sources.

1
yum -y groupinstall "Development Tools"

Download Node.js source code. Navigate to /usr/src directory, download the
source file.You can find the latest Node.js source code in Node.js Official Download Page.

1
2
3
4
5
6
cd /usr/src
wget http://nodejs.org/dist/v0.10.29/node-v0.10.29.tar.gz
# uncompress the tarball
tar zxf node-v0.10.29.tar.gz
cd node-v0.10.29

Now we are ready to install.

1
2
3
./configure
make
make install

After the install process done, run node -v to check if it was installed correctly.

Note: to enable to run an executable in /usr/local/bin through sudo, you
have to add /usr/local/bin to your secure_path using visudo:

1
sudo visudo

Find the secure_path and add :/usr/local/bin to the end of the path string.
Don’t forget the prefix colon.

Reference:

0%