无法加载Contextify

无法加载Contextify

本文介绍了无法使用node.js安装jquery-无法加载Contextify的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新-参见帖子底部

我正在尝试在node.js中设置jquery,但遇到了一些麻烦.正如在SO上描述的那样 m用npm install jquery安装jquery并从命令行将我的javascript作为脚本执行,而不是作为服务器运行.

I'm trying to setup jquery in node.js and having some trouble. As described on SO I'm installing jquery with npm install jquery and am executing my javascript as a script from the command line, rather than running it as a server.

需要注意的几点:

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

因此,从包含我的节点脚本的目录中,我npm install jquery.然后,终端关闭5秒钟,然后执行一些操作,尤其是下载模块并构建上下文.最后,消息是'build' finished successfully.

So, from the directory that contains my node script, I npm install jquery. Terminal then goes off for 5 seconds and does a few things, particularly, download the modules and build contextify. At the end, the message is 'build' finished successfully.

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

Also, from the install log I see:

  • htmlparser 1.7.4
  • jsdom 0.2.10

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

I try to run my script at this point: ./script.js, but this is output:

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'.

因此,我执行以下操作:

So, I do the following:

$ 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.以下是完整的错误消息:

However, I still get the Internal Contextify ERROR when I run my script. Below is the full error message:

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的输出,这对我来说确实很奇怪,但是除了它对我来说是意外之外,我不知道该怎么做.

It does seem strange to me that not found is the output of Checking for node path when compiling, but I don't know what to make of it other than that it is unexpected to me.

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

If anyone can offer any suggestions, I would greatly appreciate it!

更新-12/2/21

经过更多研究,我已经能够修复未找到节点路径的可能性.在终端中执行以下命令后,在构建过程中找到节点路径:export NODE_PATH="/usr/local/lib/node".但是,在删除jquery模块并再次安装/构建之后,我仍然处于相同的情况.

After some more research, I have been able to fix the oddity of node path not being found. After executing: export NODE_PATH="/usr/local/lib/node" in terminal, node path is found during the build process. However, after removing the jquery module and installing/building again, I am still in the same situation.

contextify.node文件存在于指定的发行目录中,但仍无法由我的脚本加载.

The contextify.node file exists in the specified release directory, but it still cannot be loaded by my script.

推荐答案

因此,这似乎是32位与64位之间的问题,并且在本桥特别与node.js v0.6.11有关.显然Contextify是一个64位库,但是node.js 0.6.11的下载是一个32位可执行文件.降级到v0.6.10似乎对我有用.

So this appears to be an issue with 32-bit vs 64-bit and is specifically related to node.js v0.6.11 at this pont. Apparently Contextify is a 64-bit library, but the download of node.js 0.6.11 was a 32-bit executable. Downgrading to v0.6.10 appears to work for me.

不确定这对未来意味着什么,但这是我为感兴趣的其他人找到的资源:

Not sure what this means for the future, but here are the resources I found for anyone else interested:

  • https://github.com/brianmcd/contextify/issues/19
  • http://www.websector.de/blog/2011/12/15/quick-tip-node-how-to-downgrade-node-js-on-os-x/

这篇关于无法使用node.js安装jquery-无法加载Contextify的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 02:54