I recently had the task of installing NodeJS 0.8 on CentOS 5.7. I was expecting it to be an uphill battle, but it really wasn’t too bad once I realised what needed doing. These are the instructions for installing the latest version (which was 0.8.18 at time of writing)
The first thing to do is to install some dependencies. I install a newer version of gcc to squeeze out every last drop of performance that we can get.
sudo yum install gcc44 gcc44-c++ python26
Next, we set up our current session to use the new compilers:
export CC=gcc44 export GCC=g++44
Then, it’s time to patch node to use the python26 binary instead of the built in 2.4. You need to edit
tools/install.py. If you’d prefer something a bit easier, here’s a patch file that makes the required changes. Save it into a file, and
cd into your extracted source folder and run
patch -p1 < /path/to/this-file.path to apply it
diff -uNr node-base/configure node-me/configure --- node-base/configure 2012-12-12 17:44:54.000000000 -0500 +++ node-me/configure 2013-01-08 07:24:39.000000000 -0500 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python26 import optparse import os import pprint diff -uNr node-base/Makefile node-me/Makefile --- node-base/Makefile 2012-12-12 17:44:54.000000000 -0500 +++ node-me/Makefile 2013-01-08 09:23:11.000000000 -0500 @@ -1,7 +1,7 @@ -include config.mk BUILDTYPE ?= Release -PYTHON ?= python +PYTHON ?= python26 DESTDIR ?= SIGN ?= diff -uNr node-base/tools/install.py node-me/tools/install.py --- node-base/tools/install.py 2012-12-12 17:44:54.000000000 -0500 +++ node-me/tools/install.py 2013-01-08 07:47:52.000000000 -0500 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python26 import errno import json
Once that’s been applied, you should get some output that looks similar to:
[[email protected] node-v0.8.18]$ patch -p1 < centos57.patch patching file configure patching file Makefile patching file tools/install.py Hunk #1 succeeded at 1 with fuzz 1.
After that, it’s a simple matter of running the following:
make && sudo make install
You can check that it’s installed fine by running the following commands. As of writing, you should get 0.8.18 and 1.2.2
node -v; npm -v