安装contextify-node-gyp重build失败时出错

编辑

我升级了节点并运行了“npm install -g contextify”它看起来好像安装的很好(没有错误),但是input“哪个比较”没有任何回报。 安装文章时的消息:

npm http GET https://registry.npmjs.org/contextify npm http 304 https://registry.npmjs.org/contextify npm http GET https://registry.npmjs.org/bindings npm http 304 https://registry.npmjs.org/bindings > contextify@0.1.6 install /usr/local/share/npm/lib/node_modules/contextify > node-gyp rebuild CXX(target) Release/obj.target/contextify/src/contextify.o SOLINK_MODULE(target) Release/contextify.node SOLINK_MODULE(target) Release/contextify.node: Finished contextify@0.1.6 /usr/local/share/npm/lib/node_modules/contextify └── bindings@1.1.1 

原版的

我遇到了一个问题,用npm安装symxtify:

 npm install -g contextify 

并获得以下错误消息:

 npm http GET https://registry.npmjs.org/contextify npm http 304 https://registry.npmjs.org/contextify npm http GET https://registry.npmjs.org/bindings npm http 304 https://registry.npmjs.org/bindings > contextify@0.1.6 install /usr/local/share/npm/lib/node_modules/contextify > node-gyp rebuild CXX(target) Release/obj.target/contextify/src/contextify.o SOLINK_MODULE(target) Release/contextify.node SOLINK_MODULE(target) Release/contextify.node: Finished /usr/local/Cellar/node/0.10.1/lib/node_modules/npm/bin/node-gyp-bin/node-gyp: line 2: 73593 Segmentation fault: 11 node "`dirname "$0"`/../../node_modules/node-gyp/bin/node-gyp.js" "$@" npm ERR! contextify@0.1.6 install: `node-gyp rebuild` npm ERR! `sh "-c" "node-gyp rebuild"` failed with 139 npm ERR! npm ERR! Failed at the contextify@0.1.6 install script. npm ERR! This is most likely a problem with the contextify package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node-gyp rebuild npm ERR! You can get their info via: npm ERR! npm owner ls contextify npm ERR! There is likely additional logging output above. npm ERR! System Darwin 13.0.0 npm ERR! command "/usr/local/Cellar/node/0.10.1/bin/node" "/usr/local/bin/npm" "install" "-g" "contextify" npm ERR! cwd /Users/projects/ npm ERR! node -v v0.10.1 npm ERR! npm -v 1.2.15 npm ERR! code ELIFECYCLE 

任何人都知道这里发生了什么? 我读到,它可能有一些事情要做我的PYTHON PATH,但我不知道它应该看起来如何。

谢谢您的帮助。

原来的问题

分割错误:11节点“ dirname "$0"

这似乎是通过与Clang编译暴露的V8中的一个错误。 它已经在更新版本的Node中修复,所以你需要更新。 github问题在这里被跟踪

编辑问题

没有任何可以运行的主题化的命令行程序,所以没有什么可以find的。 通过使用require('contextify')来加载模块, contextify模块将用于node内部。

根据你如何描述这一点,似乎你可能会混淆两件事情。 使用npm install -g安装的模块将全局安装,并且可供所有节点应用程序访问,但这并不意味着它们将公开可在命令行上执行的脚本。 -g只控制模块的安装path。

模块是否具有可以运行的命令行脚本取决于模块的package.json是否定义了一组bin命令,例如jshint 。 使用-g安装时,列出的脚本将与node一起链接,以便通过PATH访问它们。 在没有-g情况下安装时,bin脚本会被安装到node_modules/.bin ,您必须将该目录添加到您的PATH才能运行脚本。

我有与node-gyp rebuild相同的问题。 解决scheme是安装g ++

 apt-get -y install g++ 

没有二元contextify东西。 在/usr/lib/node_modules/contextify/build/Release/ (当在我的ubuntu 12.04中全局安装时)有contextify.node二进制文件。

只需在你的节点程序中使用require('contextify')就可以工作。

 var Contextify = require('contextify'); var sandbox = Contextify(); // returns an empty contextified object. sandbox.run('var x = 3;'); console.log(sandbox.x); // prints 3 sandbox.dispose();