在 CentOS 5 上安装 Node.js
我对 CentOS (5) 和 Node.js 都很陌生,但我已经有了旧版本的 Node.js 可以在我的虚拟服务器上运行。 现在我正在尝试安装较新的版本,并且我知道 CentOS 需要 Python 2.4,而 Node 需要 2.6 或更高版本,因此我使用 altinstall 安装了 Python 2.7。
但即使我在运行 ./configure 之前为 Python 设置了一个指向版本 2.7 的别名,我仍然会收到此错误:
/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”。我也尝试用其他东西替换它,尽管我认为它在使用 Python 别名时应该可以工作
我需要做什么才能让它工作有什么想法吗?
谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我在 Centos 5.x 上安装了 python 2.7.3 'altinstalled',二进制文件名为“/usr/local/bin/python2.7”
我使用以下命令编译并安装 Nodejs v0.8.16:
(之前我仍然必须一一识别并安装缺少的开发模块)安装将会成功)
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:
(I still had to identify and install missing development modules one by one before the install would succeed)
我更改了 bash_profile 中的 PATH 以包含所需版本的 python 的路径,如下所示:
vi ~/.bash_profile
替换 PATH=$PATH:$HOME/bin
路径=/usr/local/python272/bin:$PATH:$HOME/bin
源~/.bash_profile
./配置
make
它会选择正确的 python 版本。无需更改 wscript
我使用的是 CentOS 5.6、python 2.7.2(安装在 /usr/local/python272 中)并使用 node.js 0.4.12
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
我遇到了同样的问题。我最终编辑了 wscript 文件,并将该行 (222) 从:
...更改为:
I ran into this same exact problem. I wound up editing the wscript file and changed that line (222) from this:
...to this: