本文介绍了无法配置node.js在OS X(Snow Leopard)上进行安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我克隆了节点git repo,但是节点随附的"waf"构建工具似乎不适用于最新版本的Python.

I cloned the node git repo but the "waf" build tool that comes with node seems to not work with the latest version of Python.

$ ./configure
Traceback (most recent call last):
  File "/Users/greim/nodestuff/node/tools/waf-light", line 157, in <module>
    import Scripting
  File "/Users/greim/nodestuff/node/tools/wafadmin/Scripting.py", line 146
    except Utils.WafError, e:
                         ^
SyntaxError: invalid syntax
$ which python
/Library/Frameworks/Python.framework/Versions/3.0/bin/python

据我了解,逗号是一种过时的语法,在Python 3上不起作用,对吧?

If I understand, that comma is an outdated syntax that doesn't work on Python 3, right?

我不想仅仅为了执行此操作而安装旧版本的Python.理想情况下,我希望能够构建和安装最新版本,而不是依赖于其他人来分发.dmg文件.

I'd rather not install an old version of Python just to do this. Ideally I'd like to be able to build and install the latest version, rather than depend on others to distribute .dmg files.

岩石和困难的地方?建议?

Rock and hard place? Recommendations?

[更新]好的,感谢所有帮助回答此问题的人.希望其他人可以在Google上找到它.事实证明,我的系统上确实有Python 2.x(它默认安装在OS X上)在/usr/bin下.因此解决方案是更新我的路径(不是永久性的,仅用于此bash会话).

[update] OK, so thanks to all who helped answer this question. Hopefully others will find this on Google. As it turns out I do have Python 2.x on my system (it comes installed by default on OS X) under /usr/bin. So the solution was to update my path (not permanently, just for this one bash session).

$ export PATH=/usr/bin:$PATH
$ ./configure
$ make
$ make install

多田! Node已安装在我的系统上.

Tada! Node is installed on my system.

推荐答案

I waf项目页面

我认为它当前是通过在解压缩时运行2to3.py来完成此操作的,因此,如果您首先使用python2运行,则可能是错误的.我认为waf1.6分支是python3 clean

I think it currently does this by running 2to3.py when unpacking so if you had run first with python2 then it might be wrong. The waf1.6 branch I think is python3 clean

阅读 node.js代码节点人员扩展了waf-这不是使用waf的本意.想法是将waf二进制文件放入源代码中-它将使用正确版本的python进行扩展

Reading the node.js code the node people expanded waf - which is not how you are meant to use waf. The idea is put the waf binary in the source code - this will expand using the correct version of python

OSX确实具有python 2,因此运行构建的一种方法可能是编辑根makefile并替换第一行

OSX does have python 2 so a way of running the build might be to edit the root makefile and replace the first line

WAF=python tools/waf-light

通过

WAF=/usr/bin/python tools/waf-light

这篇关于无法配置node.js在OS X(Snow Leopard)上进行安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 15:44