在 CentOS 5 上安装 Node.js

发布于 2024-11-29 22:08:43 字数 1199 浏览 3 评论 0原文

我对 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

清君侧 2024-12-06 22:08:43

我在 Centos 5.x 上安装了 python 2.7.3 'altinstalled',二进制文件名为“/usr/local/bin/python2.7”

我使用以下命令编译并安装 Nodejs v0.8.16:

PYTHON=/usr/local/bin/python2.7
export PYTHON
python2.7 configure && make && make install
  • 运行 configure使用 python2.7 覆盖默认的 python 处理,
  • 创建 PYTHON env var 允许 ma​​ke install 找到正确的 python 版本

(之前我仍然必须一一识别并安装缺少的开发模块)安装将会成功)

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)

离线来电— 2024-12-06 22:08:43

我更改了 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

泪之魂 2024-12-06 22:08:43

我遇到了同样的问题。我最终编辑了 wscript 文件,并将该行 (222) 从:

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

...更改为:

""

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:

""
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文