无法与node.js安装jquery – 无法加载Contextify

更新 – 请参阅post的底部

我试图在node.js中设置jquery,并有一些麻烦。 如上所述,我正在安装jquery与npm install jquery并执行我的JavaScript作为脚本从命令行,而不是运行它作为服务器。

有几点需要注意:

  • OS X 10.7.3
  • node.js版本0.6.11
  • npm版本1.1.1
  • 节点waf版本1.5.16

所以,从包含我的节点脚本的目录,我npm install jquery 。 terminal然后closures5秒钟,并做了一些事情,特别是,下载模块和构buildcontextify。 最后,消息'build' finished successfully

另外,从安装日志中我看到:

  • htmlparser 1.7.4
  • jsdom 0.2.10

我尝试运行我的脚本: ./script.js ,但是这是输出:

 Internal Contextify ERROR: Make sure Contextify is build with your current Node version. To rebuild, go to the Contextify root folder and run 'node-waf distclean && node-waf configure build'. 

所以,我做了以下几点:

 $ cd node_modules/jquery/node_modules/jsdom/node_modules/contextify/ $ node-waf distclean && node-waf configure build 'distclean' finished successfully (0.002s) Setting srcdir to: /proj/node_modules/jquery/node_modules/jsdom/node_modules/contextify Setting blddir to: /proj/node_modules/jquery/node_modules/jsdom/node_modules/contextify/build Checking for program g++ or c++ : /usr/bin/g++ Checking for program cpp : /usr/bin/cpp Checking for program ar : /usr/bin/ar Checking for program ranlib : /usr/bin/ranlib Checking for g++ : ok Checking for node path : not found Checking for node prefix : ok /usr/local 'configure' finished successfully (0.729s) Waf: Entering directory `/proj/node_modules/jquery/node_modules/jsdom/node_modules/contextify/build' [1/2] cxx: src/contextify.cc -> build/Release/src/contextify_1.o [2/2] cxx_link: build/Release/src/contextify_1.o -> build/Release/contextify.node Waf: Leaving directory `/proj/node_modules/jquery/node_modules/jsdom/node_modules/contextify/build' 'build' finished successfully (3.335s) 

但是,当我运行我的脚本时,仍然收到Internal Contextify ERROR 。 以下是完整的错误消息:

 Internal Contextify ERROR: Make sure Contextify is built with your current Node version. To rebuild, go to the Contextify root folder and run 'node-waf distclean && node-waf configure build'. node.js:201 throw e; // process.nextTick error, or 'error' event on first tick ^ Error: Unable to load shared library /proj/node_modules/jquery/node_modules/jsdom/node_modules/contextify/build/Release/contextify.node at Object..node (module.js:472:11) at Module.load (module.js:348:31) at Function._load (module.js:308:12) at Module.require (module.js:354:17) at require (module.js:370:17) at Object.<anonymous>(/proj/node_modules/jquery/node_modules/jsdom/node_modules/contextify/lib/contextify.js:2:22) at Module._compile (module.js:441:26) at Object..js (module.js:459:10) at Module.load (module.js:348:31) at Function._load (module.js:308:12) 

我觉得在编译时not found Checking for node path的输出,但我不知道该怎么做,除此之外对我来说是意想不到的。

如果有人能提供任何build议,我将不胜感激!

更新 – 2/21/12

经过更多的研究,我已经能够解决找不到的节点path的怪异。 执行完毕后,在terminalexport NODE_PATH="/usr/local/lib/node"export NODE_PATH="/usr/local/lib/node"过程中find节点path。 但是,删除jquery模块并重新安装/构build后,我仍处于相同的情况。

contextify.node文件存在于指定的版本目录中,但仍无法通过脚本加载。

所以这似乎是一个32位和64位的问题,特别是与这个pont的node.js v0.6.11相关。 显然Contextify是一个64位的库,但下载node.js 0.6.11是一个32位的可执行文件。 降级到v0.6.10似乎适用于我。

不知道这对未来意味着什么,但是这里是我为其他感兴趣的人find的资源: