Error installing contextify- node-gyp rebuild fail

2019-02-04 15:29发布

Edit

I upgraded node and ran "npm install -g contextify" It looks like it installed fine (no errors), but typing in "which contextify" returns nothing. Message while installing 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

Original

I'm having a problem installing contextify with npm:

npm install -g contextify

and get the following error messages:

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

Anyone know what's going on here? I read that it may have something to do wit my PYTHON PATH, but I'm not sure how it should look.

Thanks for the help.

3条回答
一夜七次
2楼-- · 2019-02-04 15:40

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

apt-get -y install g++
查看更多
迷人小祖宗
3楼-- · 2019-02-04 15:41

There is no such thing as contextify binary. There is contextify.node binary in /usr/lib/node_modules/contextify/build/Release/ (when installed globally in my ubuntu 12.04).

Just use the module in your node program by using require('contextify') and it should work.

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();
查看更多
男人必须洒脱
4楼-- · 2019-02-04 15:42

Original problem

Segmentation fault: 11 node "dirname "$0"

This appears to be a bug in V8 exposed by compiling with Clang. It's been fixed in more recent versions of Node, so you'll need to update. The github issue is tracked here

Edit problem

There is no contextify command-line program that you can run, so which contextify has nothing to find. The contextify module is meant to be used within node by using require('contextify') to load the module.

Based on how you've described this, it seems like you may be conflating two things. Modules installed with npm install -g are installed globally and accessible to all node applications, but that does not mean that they will expose a script that can be executed on the command line. -g only controls the installation path of the module.

Whether a module has a command-line script you can run depends on whether the module's package.json defines a set of bin commands, e.g. jshint. When you install with -g, the scripts listed are symlinked along with node so they are accessible via your PATH. When installed without -g, bin scripts are installed into node_modules/.bin and you would have to add that directory to your PATH for scripts to work.

查看更多
登录 后发表回答