更新 - 见帖子底部
我正在尝试在 node.js 中设置 jquery 并且遇到了一些麻烦。如SO 所述,我正在安装 jquerynpm install jquery
并从命令行将我的 javascript 作为脚本执行,而不是将其作为服务器运行。
需要注意的几点:
- OS X 10.7.3
- node.js 版本 0.6.11
- npm 版本 1.1.1
- 节点 waf 版本 1.5.16
因此,从包含我的节点脚本的目录中,我npm install jquery
. 然后终端会关闭 5 秒钟并执行一些操作,特别是下载模块并构建 contextify。最后,消息是'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
,但我不知道该怎么做,除了这对我来说是出乎意料的。
如果有人可以提供任何建议,我将不胜感激!
更新 - 2/21/12
经过更多研究,我已经能够解决找不到节点路径的奇怪问题。执行后:export NODE_PATH="/usr/local/lib/node"
在终端中,在构建过程中找到节点路径。但是,在删除 jquery 模块并再次安装/构建后,我仍然处于同样的情况。
contextify.node 文件存在于指定的发布目录中,但我的脚本仍然无法加载它。