修改
我升级了节点并运行了“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
原始
我在使用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有关,但我不确定它应该是什么样的。
感谢您的帮助。
答案 0 :(得分:11)
node-gyp rebuild
我遇到了同样的问题。解决方案是安装 g ++ :
apt-get -y install g++
答案 1 :(得分:4)
分段错误:11个节点“
dirname "$0"
这似乎是通过使用Clang进行编译而暴露的V8中的错误。它已在更新版本的Node中修复,因此您需要更新。跟踪github问题here
您无法运行contextify
命令行程序,因此which contextify
无法找到。 contextify
模块旨在node
中使用require('contextify')
加载模块。
根据您对此的描述,您似乎可能会混淆两件事。安装有npm install -g
的模块全局安装并可供所有节点应用程序访问,但这并不意味着它们将公开可在命令行上执行的脚本。 -g
仅控制模块的安装路径。
模块是否具有可以运行的命令行脚本取决于模块的package.json
是否定义了一组bin
命令,例如jshint。当您使用-g
进行安装时,列出的脚本会与node
一起进行符号链接,以便可以通过PATH
访问这些脚本。在没有-g
的情况下安装时,bin脚本会安装到node_modules/.bin
中,您必须将该目录添加到PATH
以使脚本生效。
答案 2 :(得分:1)
没有contextify
二进制这样的东西。 contextify.node
中有/usr/lib/node_modules/contextify/build/Release/
个二进制文件(在我的ubuntu 12.04中全局安装时)。
只需使用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();