Installing nodejs 0.8 on CentOS 5.7

This article was published 6 years ago. Due to the rapidly evolving world of technology, some concepts may no longer be applicable.

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 configure, Makefile and tools/ 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 @@

 BUILDTYPE ?= Release
-PYTHON ?= python
+PYTHON ?= python26
 SIGN ?=

diff -uNr node-base/tools/ node-me/tools/
--- node-base/tools/  2012-12-12 17:44:54.000000000 -0500
+++ node-me/tools/    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/
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

Thoughts on this post

Joe Flynn 2013-01-24

Thanks for posting this! I’d been fighting with trying to get this working for a while now & this worked fantastic.

[…] I blog about things that I couldn’t find solutions to and had to work out myself (e.g. Node on CentOS 5.7), sometimes about things that I did find help […]

Leave a comment?

Leave a Reply