开发者

Installing node.js on CentOS 5

开发者 https://www.devze.com 2023-03-28 13:25 出处:网络
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.

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:

开发者_JAVA百科
/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!


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)


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


I ran into this same exact problem. I wound up editing the wscript file and changed that line (222) from this:

"-pre" if node_is_release == "0" else ""

...to this:

""
0

精彩评论

暂无评论...
验证码 换一张
取 消