gyp_main.py: error: no such option: --no-parallel

gyp_main.py: error: no such option: --no-parallel

运行 npm install 安装 sinopia 项目的开发依赖,我得到这个 node-gyp configure error:

> fs-ext@0.4.5 install /home/remi/_projects/gitlab/SWAP/sirap-private-npm/node_modules/fs-ext
> node-gyp configure build

Usage: gyp_main.py [options ...] [build_file ...]

gyp_main.py: error: no such option: --no-parallel
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onCpExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:340:16)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:820:12)
gyp ERR! System Linux 3.16.0-29-generic
gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build"
gyp ERR! cwd /home/remi/_projects/gitlab/SWAP/sirap-private-npm/node_modules/fs-ext
gyp ERR! node -v v0.10.40
gyp ERR! node-gyp -v v0.13.0
gyp ERR! not ok 

尝试过

npm cache clean

npm install

有时但没有效果。总是抛出这个错误。 node-gyp 无法构建。

gyp似乎依赖于python 2.6,目前还不支持python 2.7

您必须降级 python 版本,感谢 fkrull's PPA:

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

如果您想稍后更改此选择

sudo update-alternatives --config python

此 CLI 界面会询问您自动使用哪个版本,必须手动使用哪个版本。

然后,在您的项目文件夹中:

npm cache clean
npm install

现在可以了。

使用这个来升级npm内部使用的gyp版本:

sudo npm explore npm -g -- npm install node-gyp@latest

https://github.com/nodejs/node-gyp/wiki/Updating-npm%27s-bundled-node-gyp