在 ubuntu 上安装 node-gyp 时出错 [英] Error installing node-gyp on ubuntu
本文介绍了在 ubuntu 上安装 node-gyp 时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
npm http 200 https://registry.npmjs.org/weak/-/weak-0.2.2.tgznpm http GET https://registry.npmjs.org/bindingsnpm http 304 https://registry.npmjs.org/bindings>weak@0.2.2 安装 node_modules/weak>节点gyp重建回溯(最近一次调用最后一次):文件/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py",第18行,在<module>sys.exit(gyp.script_main())AttributeError: 'module' 对象没有属性 'script_main'吉普错误!配置错误吉普错误!堆栈错误:`gyp` 失败,退出代码:1吉普错误!堆栈在 ChildProcess.onCpExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:337:16)吉普错误!堆栈在 ChildProcess.EventEmitter.emit (events.js:98:17)吉普错误!堆栈在 Process.ChildProcess._handle.onexit (child_process.js:789:12)吉普错误!系统 Linux 3.11.0-15-generic吉普错误!命令节点"/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js"重建"吉普错误!节点 -v v0.10.15吉普错误!节点-gyp -v v0.12.1吉普错误!不好npm 错误!弱@0.2.2 安装:`node-gyp 重建`npm 错误!退出状态 1npm 错误!npm 错误!在weak@0.2.2 安装脚本中失败.npm 错误!这很可能是弱包的问题,npm 错误!不是 npm 本身.npm 错误!告诉作者这在您的系统上失败:npm 错误!节点gyp重建npm 错误!您可以通过以下方式获取他们的信息:npm 错误!npm 所有者 ls 弱npm 错误!上面可能有额外的日志输出.npm 错误!系统 Linux 3.11.0-15-genericnpm 错误!命令节点"/usr/bin/npm"安装"weak@0.2.2"npm 错误!节点 -v v0.10.15npm 错误!npm -v 1.3.23npm 错误!代码生命周期npm 错误!不行 代码 0
我对weak 或node-gyp 没有直接依赖,但我想它是我的其他依赖项(express、phantom、ejs、aws-sdk、moment)所必需的.有没有人遇到过这样的问题并且能够解决?
解决方案
这是有效的.安装过程中需要python 2.6.
#!/bin/bash#On Ubuntu Saucy:sudo add-apt-repository ppa:fkrull/deadsnakessudo apt-get 更新须藤 apt-get 安装 python2.6须藤更新替代品 --install/usr/bin/python python/usr/bin/python2.6 20须藤更新替代品 --install/usr/bin/python python/usr/bin/python2.7 10#您可以在 2.6 和 2.6 之间切换2.7 使用:须藤更新替代品 --config python#顺便说一句,我使用 ppa:chris-lea/node.js 安装了节点
https://github.com/TooTallNate/node-gyp/issues/363>
npm http 200 https://registry.npmjs.org/weak/-/weak-0.2.2.tgz
npm http GET https://registry.npmjs.org/bindings
npm http 304 https://registry.npmjs.org/bindings
> weak@0.2.2 install node_modules/weak
> node-gyp rebuild
Traceback (most recent call last):
File "/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 18, in <module>
sys.exit(gyp.script_main())
AttributeError: 'module' object has no attribute 'script_main'
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:337:16)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Linux 3.11.0-15-generic
gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! node -v v0.10.15
gyp ERR! node-gyp -v v0.12.1
gyp ERR! not ok
npm ERR! weak@0.2.2 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the weak@0.2.2 install script.
npm ERR! This is most likely a problem with the weak 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 weak
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 3.11.0-15-generic
npm ERR! command "node" "/usr/bin/npm" "install" "weak@0.2.2"
npm ERR! node -v v0.10.15
npm ERR! npm -v 1.3.23
npm ERR! code ELIFECYCLE
npm ERR! not ok code 0
I don't have a direct dependency on weak or node-gyp but I guess it is required by my other dependencies (express,phantom,ejs,aws-sdk,moment). Anyone faced such an issue and was able to fix?
解决方案
This is what worked. You need python 2.6 during the installation.
#!/bin/bash
#On Ubuntu Saucy:
sudo add-apt-repository ppa:fkrull/deadsnakes
sudo apt-get update
sudo apt-get install python2.6
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.6 20
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 10
#you can switch between 2.6 & 2.7 using:
sudo update-alternatives --config python
#Btw I installed node using ppa:chris-lea/node.js
https://github.com/TooTallNate/node-gyp/issues/363
这篇关于在 ubuntu 上安装 node-gyp 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文