节点10-NPM安装期间出现“ node-gyp rebuild”错误

时间:2019-01-17 13:26:11

标签: node.js node-gyp

我最近已升级到节点10,运行npm install时出现以下错误:

make: *** [Release/obj.target/memwatch/src/init.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
gyp ERR! System Darwin 18.2.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/david/Documents/gitlab/project/node_modules/memwatch-next
gyp ERR! node -v v10.15.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! memwatch-next@0.3.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the memwatch-next@0.3.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

在'macOS Mojave'上工作时,我与Node10一起在同一项目上工作,没有任何问题。 请告知是什么原因导致错误?

6 个答案:

答案 0 :(得分:1)

通过将npm更新到最新版本并运行npm rebuild解决了该问题。

答案 1 :(得分:1)

使用 NVM 管理节点。这真的很有帮助。我遇到了同样的错误,但通过使用最新的 Node LTS 版本解决了它。使用 NVM 只需一个命令即可轻松完成。

nvm install --lts

答案 2 :(得分:0)

在不知道实际的node-gyp错误的情况下,请确保已为平台安装了node-gyp dependencies

答案 3 :(得分:0)

我遇到了同样的问题,并通过删除yarn.lock 文件然后再次运行yarn install

来解决。

答案 4 :(得分:0)

我认为删除此目录更好:

rm -rf ~/.node-gyp/
rm -r node_modules/.bin/;
rm -r build/

您可以测试

npm install -g node-gyp

npm install -g node-pre-gyp

最后:

npm install <your module>

答案 5 :(得分:0)

我有同样的问题。首先,我删除了package.json并运行npm install,但这没有帮助。 只有回到以前的稳定节点版本才对我有所帮助。 (nvm非常有用)

相关问题