【问题标题】:Error installing contextify- node-gyp rebuild failed安装 contextify 时出错-node-gyp 重建失败
【发布时间】:2023-04-09 12:35:01
【问题描述】:

编辑

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

感谢您的帮助。

【问题讨论】:

  • 你能添加更多的输出吗?它应该说明本节上方的错误是什么。你在小牛队吗?
  • 好的,刚刚添加。我也在小牛队。
  • 看起来这可能是a bug in Node,您尝试过更新的版本吗? v0.10.1 来自近 10 个月前。
  • 更新节点和线程

标签: node.js topojson node-gyp contextify


【解决方案1】:

node-gyp rebuild 也有同样的问题。解决方案是安装 g++

apt-get -y install g++

【讨论】:

    【解决方案2】:

    原来的问题

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

    这似乎是使用 Clang 编译时暴露的 V8 中的一个错误。它已在较新版本的 Node 中得到修复,因此您需要更新。 github问题跟踪here

    编辑问题

    没有可以运行的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 中的任何内容?
    • 通常不会。通常,Node 会将自己安装到标准应用程序目录中,该目录已经在您的路径中。
    • 看起来它还不支持 node 4.x:github.com/brianmcd/contextify/issues/180
    【解决方案3】:

    没有像contextify 二进制这样的东西。 /usr/lib/node_modules/contextify/build/Release/ 中有 contextify.node 二进制文件(当在我的 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();
    

    【讨论】:

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