安装contextify出错- node-gyp重建失败

13

编辑

我升级了Node并运行了"npm install -g contextify"。看起来它安装成功了(没有错误),但在键入“which contextify”时什么都没有返回。在安装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
contextify@0.1.6 /usr/local/share/npm/lib/node_modules/contextify
└── bindings@1.1.1

Translated

我在使用npm安装contextify时遇到了问题:

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有关,但我不确定它应该是什么样子。

谢谢帮忙。


你能添加更多的输出吗?它应该在这个部分上面说出错误是什么。你使用的是Mavericks操作系统吗? - loganfsmyth
当然,我已经添加了它。我也在使用Mavericks操作系统。 - ukejoe
看起来这可能是Node的一个bug,你尝试过更近期的版本了吗?v0.10.1已经发布将近10个月了。 - loganfsmyth
更新了节点和线程。 - ukejoe
3个回答

11

我遇到了与node-gyp rebuild相同的问题。解决方法是安装g++

apt-get -y install g++

4

原始问题

分段错误: 11 节点 "dirname "$0"

这似乎是由使用Clang编译时V8的一个错误。在更近期的Node版本中已经修复,因此您需要更新。Github问题跟踪在这里

编辑问题

没有可以运行的contextify命令行程序,因此which contextify找不到任何内容。 contextify模块是通过使用require('contextify')node内部使用的加载该模块。

根据您的描述方式,似乎您可能混淆了两个东西。使用npm install -g安装的模块是全局安装并可供所有节点应用程序访问,但这并不意味着它们将公开可在命令行上执行的脚本。 -g仅控制模块的安装路径。

无论一个模块是否有命令行脚本取决于该模块的package.json是否定义了一组bin命令,例如jshint。当你使用-g安装时,列出的脚本会与node一起建立符号链接,因此可以通过你的PATH访问它们。如果没有使用-g安装,则bin脚本会被安装到node_modules/.bin中,你需要将该目录添加到PATH中以使脚本正常工作。

好的,我想我明白你的意思了。这就引出了另一个问题。当我全局安装包时,我需要更改我的 PATH 吗? - ukejoe
通常情况下不需要。一般来说,Node会自动安装到标准应用程序目录中,该目录已经在您的路径中了。 - loganfsmyth
2
看起来它还不支持node 4.x: https://github.com/brianmcd/contextify/issues/180 - loganfsmyth

-1

不存在名为contextify的二进制文件。在我的Ubuntu 12.04中全局安装时,存在于/usr/lib/node_modules/contextify/build/Release/中的contextify.node二进制文件。

只需通过require('contextify')在您的Node程序中使用该模块即可。

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();

2
我不太确定你在说什么。 我在/usr/lib/local/node_modules中没有/contextify。 - ukejoe

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接