問題描述
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
我沒有對弱或node-gyp的直接依賴,但是我想我的其他依賴(express,phantom,ejs,aws-sdk,moment)是必需的。任何人都遇到這樣的問題並能夠解決?
最佳回答
如果您的python版本不是錯誤源,請檢查是否已安裝”gyp”。這與node-gyp中的gyp版本衝突。
apt-get remove gyp
https://github.com/TooTallNate/node-gyp/issues/363#issuecomment-32234646
次佳回答
在我的情況下,此命令sudo apt-get install build-essential
有所幫助。
第三種回答
這是有效的。在安裝過程中需要python 2.6。
#!/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
第四種回答
FWIW,我在嘗試在Ubuntu 14.04(DigitalOcean)上安裝Protractor時遇到類似的問題。重新安裝node-gyp修複了它:
apt-get install node-gyp
第五種回答
在Ubuntu 18上,我必須安裝所需的構建庫才能使其正常運行
sudo apt-get install build-essential
第六種回答
以下是在Ubuntu係統上成功安裝node-gyp的步驟:
1.首先,使用以下命令在Ubuntu中安裝”make”構建工具:
sudo apt-get update && \
sudo apt-get install build-essential software-properties-common -y;
2.然後,您需要安裝適當的C /C++編譯器工具鏈。我們將使用以下命令在此處安裝GCC:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
sudo apt-get update && \
sudo apt-get install gcc-snapshot -y && \
sudo apt-get update && \
sudo apt-get install gcc-6 g++-6 -y && \
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 60 --slave
/usr/bin/g++ g++ /usr/bin/g++-6 && \
sudo apt-get install gcc-4.8 g++-4.8 -y && \
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 60 --slave
/usr/bin/g++ g++ /usr/bin/g++-4.8;
3.安裝python 2.7版本。 (注意:node-gyp不支持Python 3)。
sudo apt update
sudo apt upgrade
sudo apt install python2.7 python-pip
4.最後安裝node-gyp npm軟件包:
npm install -g node-gyp
附加但不重要:如果您有與node-gyp有關的原子keyboard-layout相關的問題,請再安裝以下軟件包:
sudo apt-get install libxkbfile-dev
就這樣!現在應該可以正常工作了。
第七種回答
我在嘗試安裝Wikimedia擴展Mathoid時在Ubuntu 16.04上遇到了此問題。
我嘗試了所有建議的方法,但直到執行以下任何操作為止:
sudo apt-get install librsvg2-2 librsvg2-dev