Instantly share code, notes, and snippets.

What would you like to do?
Install Node.js on Centos 5.11

Node.js requires python version 2.6 or higher

sudo rpm -ivh epel-release-5-4.noarch.rpm
sudo yum install python26

Python 2.6 will now be installed in /usr/bin/python26

Install GCC 4.4

sudo yum install gcc44
sudo yum install gcc44-c++

Move old gcc aside and symlink new one

sudo mv /usr/bin/gcc /usr/bin/gcc41
sudo ln -s /usr/bin/gcc44 /usr/bin/gcc
sudo mv /usr/bin/g++ /usr/bin/g++41
sudo ln -s /usr/bin/g++44 /usr/bin/g++
sudo mv /usr/bin/python /usr/bin/python214
sudo ln -s /usr/bin/python26 /usr/bin/python

Download Node.js and compile with python 2.6:

tar vxzf node-v0.12.2.tar.gz
cd node-v0.12.2

sudo make install

Symlink back to defaults

sudo rm -f /usr/bin/python
sudo ln -s /usr/bin/python214 /usr/bin/python
sudo rm -f /usr/bin/gcc
sudo ln -s /usr/bin/gcc41 /usr/bin/gcc
sudo rm -f /usr/bin/g++
sudo ln -s /usr/bin/g++41 /usr/bin/g++

This comment has been minimized.

wizysanjay commented Jul 5, 2015

I followed the tutorial, It's successful but when I run:

[root@vps node-v0.12.6]# node -v
-bash: node: command not found


This comment has been minimized.

redreinard commented Dec 14, 2016

Thanks for this writeup, worked perfectly.
The node binary is installed in /usr/local/bin/node, either add that that to your path

$ export PATH="/usr/local/bin:$PATH"
$ node -v


$ /usr/local/bin/node -v

This comment has been minimized.

2dareis2do commented Jan 16, 2017

Awesome write up

Followed these instructions and seems to work like a charm. I did not have to update my epel-release-5-4.noarch so that made it a bit more straightforward. Also followed David Walsh's tips for updating to latest version of node using node itself. Namely:

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

FYI I tried installing latest directly at would not compile complaint about needing later version of Python.

[root@www bin]# node -v

Magic? I now have node 7 running on centsOS 5.11?


This comment has been minimized.

angelhvargas commented Feb 1, 2017

Nice guide!!! Worked perfect! Well done!


This comment has been minimized.

danielflam commented Mar 10, 2018

A few things -
install 0.12.18

Then you can use 2dareis2do method using n to install v 6 which works
sudo n 6.13.1

version 7 (at least on my system) and later has a problem with outdated LIBC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment