13

编辑

我升级了节点并运行了“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 有关,但我不确定它应该是什么样子。

谢谢您的帮助。

4

3 回答 3

11

I had the same problem with node-gyp rebuild. The solution was install g++:

apt-get -y install g++
于 2014-03-14T13:04:52.537 回答
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的脚本才能工作。

于 2014-01-16T01:42:29.263 回答
0

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

只需通过 using 在您的节点程序中使用该模块,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();
于 2014-01-16T00:27:13.490 回答