Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing node.js on CentOS 5

I'm pretty new to CentOS (5) and also node.js, but I already got an older version of node.js to work on my virtual server. Now I'm trying to install a newer version, and I know that CentOS needs Python 2.4 while node needs 2.6 or newer, so I installed Python 2.7 using altinstall.

But even if I set an alias for Python that points to version 2.7 before running ./configure, I still get this error:

/root/node/wscript: error: Traceback (most recent call last):
  File "/root/node/tools/wafadmin/Utils.py", line 274, in load_module
    exec(compile(code, file_path, 'exec'), module.__dict__)
  File "/root/node/wscript", line 222
    "-pre" if node_is_release == "0" else ""
        ^
SyntaxError: invalid syntax

That's the content of ./configure:

#! /bin/sh

# v8 doesn't like ccache
if [ ! -z "`echo $CC | grep ccache`" ]; then
  echo "Error: V8 doesn't like cache. Please set your CC env var to 'gcc'"
  echo "  (ba)sh: export CC=gcc"
  exit 1
fi

CUR_DIR=$PWD

#possible relative path
WORKINGDIR=`dirname $0`
cd "$WORKINGDIR"
#abs path
WORKINGDIR=`pwd`
cd "$CUR_DIR"

"${WORKINGDIR}/tools/waf-light" --jobs=1 configure $*

exit $?"

And at the top of wscript there is the following line: "#!/usr/bin/env python". I also tried replacing that with something else, though I think it should work when using a Python alias

Any ideas what I need to do to get this to work?

Thanks!

like image 215
north Avatar asked Aug 14 '11 12:08

north


2 Answers

I have python 2.7.3 'altinstalled' on Centos 5.x, with the binary named "/usr/local/bin/python2.7"

I compile and install nodejs v0.8.16 using:

PYTHON=/usr/local/bin/python2.7
export PYTHON
python2.7 configure && make && make install
  • running configure with python2.7 overrides the default python handling
  • creating a PYTHON env var allows make install to find the correct version of python

(I still had to identify and install missing development modules one by one before the install would succeed)

like image 101
mmccarn Avatar answered Sep 27 '22 18:09

mmccarn


I changed the PATH in bash_profile to include the path to the desired version of python as follows:

vi ~/.bash_profile
replace PATH=$PATH:$HOME/bin
with PATH=/usr/local/python272/bin:$PATH:$HOME/bin
source ~/.bash_profile
./configure
make

It picks up the correct python version. No need to change wscript

I'm on CentOS 5.6, python 2.7.2 (installed in /usr/local/python272) and using node.js 0.4.12

like image 31
Uday Shanmugam Avatar answered Sep 27 '22 17:09

Uday Shanmugam