Hybrid开发Node.js

如何解决node升级v10.5.0后 gyp ERR! buil

2018-07-15  本文已影响3612人  youthcity

问题描述

将node版本升级到 v10.5.0后,yarn install无法正常执行。

错误提示如下

make: *** [Release/obj.target/fse/fsevents.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/youthcity/.nvm/versions/node/v10.5.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:237:12)
gyp ERR! System Darwin 16.7.0
gyp ERR! command \"/Users/youthcity/.nvm/versions/node/v10.5.0/bin/node\" \"/Users/youthcity/.nvm/versions/node/v10.5.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js\" \"build\" \"--fallback-to-build\" \"--module=/Users/youthcity/Documents/github/Tiger/Tiger/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node\" \"--module_name=fse\" \"--module_path=/Users/youthcity/Documents/github/Tiger/Tiger/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64\"
gyp ERR! cwd /Users/youthcity/Documents/github/Tiger/Tiger/node_modules/fsevents
gyp ERR! node -v v10.5.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
make: *** [Release/obj.target/fse/fsevents.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/youthcity/.nvm/versions/node/v10.5.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:237:12)
gyp ERR! System Darwin 16.7.0
gyp ERR! command \"/Users/youthcity/.nvm/versions/node/v10.5.0/bin/node\" \"/Users/youthcity/.nvm/versions/node/v10.5.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js\" \"build\" \"--fallback-to-build\" \"--module=/Users/youthcity/Documents/github/Tiger/Tiger/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node\" \"--module_name=fse\" \"--module_path=/Users/youthcity/Documents/github/Tiger/Tiger/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64\"
gyp ERR! cwd /Users/youthcity/Documents/github/Tiger/Tiger/node_modules/fsevents
gyp ERR! node -v v10.5.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/Users/youthcity/.nvm/versions/node/v10.5.0/bin/node /Users/youthcity/.nvm/versions/node/v10.5.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/youthcity/Documents/github/Tiger/Tiger/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node --module_name=fse --module_path=/Users/youthcity/Documents/github/Tiger/Tiger/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/youthcity/Documents/github/Tiger/Tiger/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:961:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)
node-pre-gyp ERR! System Darwin 16.7.0
node-pre-gyp ERR! command \"/Users/youthcity/.nvm/versions/node/v10.5.0/bin/node\" \"/Users/youthcity/Documents/github/Tiger/Tiger/node_modules/fsevents/node_modules/.bin/node-pre-gyp\" \"install\" \"--fallback-to-build\"
node-pre-gyp ERR! cwd /Users/youthcity/Documents/github/Tiger/Tiger/node_modules/fsevents
node-pre-gyp ERR! node -v v10.5.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.36
node-pre-gyp ERR! not ok

解决办法

将node版本回退到 8.x.x LTS 版。

例如,若使用 nvm 管理node版本,可使用命令

nvm install v8.11.3  # 下载node
nvm alias default 8.11.3 #将 8.11.3版本设为默认版本

重启终端,重新进行 yarn install即可。

其他问题

问题描述

xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

错误原因

Xcode 重命名后,xcodebuild 找不到原来的Xcode。所以,我们重新设置 Xcode的路径。

解决办法

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

参考资料

上一篇下一篇

猜你喜欢

热点阅读