2012-02-21 85 views
1

更新 - 看帖子的底部无法与node.js的安装jQuery的 - 无法加载Contextify

我想设置的jQuery在node.js中和遇到了一些麻烦。作为described on SO我正在安装jQuery与npm install jquery并执行我的JavaScript作为脚本从命令行,而不是作为服务器运行。

有几点需要注意:

  • OS X 10.7.3
  • 的Node.js版本0.6.11
  • NPM版本1.1.1
  • 节点-WAF版本1.5.16

因此,从包含我的节点脚本的目录I npm install jquery。然后,终端会关闭5秒钟并执行一些操作,特别是下载模块并构建调解。最后,该消息是'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 foundChecking for node path编译时的输出,但我不知道是怎么打的比,这是不期而至我之外。

如果有人可以提供任何建议,我将不胜感激!

更新 - 12年2月21日

经过一些调查研究,我已经能够解决未找到节点路径的怪胎。在终端中执行:export NODE_PATH="/usr/local/lib/node"后,在构建过程中会找到节点路径。但是,删除jquery模块并重新安装/构建后,我仍处于相同的情况。

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

+0

在此同时,您可以通过一次有人回答了这个手动创建的文件,并解释为什么它的发生 – 2012-02-21 18:19:48

+0

感谢。 ,Shawn,我可以这样做,但是我不确定那个文件会是什么(我对node.js非常陌生)。有一个contextify.node文件在它的release目录中生成。多说一点,或者指点我参考? – jmac 2012-02-21 18:23:03

+0

我也很新,但是当我使用jQuery时,我只是添加了一个新的js文件并从其中一个页面链接到它。 – 2012-02-21 19:07:52

回答

1

我固定contextify问题通过以下指令说明:

“对于那些习惯了npm魔法的人来说,使用Benvie预制的二进制文件就可以了在https://github.com/Benvie/contextify/zipball/master下载ZIP文件,将其解压到您的node_modules文件夹中,然后将该文件夹重命名为“contextify”。请注意,此二进制文件只能在节点为0.6的窗口中使用,因此如果要通过非Windows用户的源代码管理共享您的node_modules文件夹,请小心。 (编辑:固定的联系,在接下来的评论中指出)”

https://github.com/brianmcd/contextify/issues/12