node-pre-gyp ERR! build error node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node

npm install 安装依赖包报如下错误

gyp ERR! cwd /Users/waterw/git/2019/ipfs/orbit-web/node_modules/gc-stats
gyp ERR! node -v v6.0.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/waterw/git/2019/ipfs/orbit-web/node_modules/gc-stats/build/gcstats/v1.2.1/Release/node-v48-darwin-x64/gcstats.node --module_name=gcstats --module_path=/Users/waterw/git/2019/ipfs/orbit-web/node_modules/gc-stats/build/gcstats/v1.2.1/Release/node-v48-darwin-x64 --node_abi_napi=node-v48 --napi_build_version=0 --node_napi_label=node-v48' (1)
node-pre-gyp ERR! stack     at ChildProcess. (/Users/waterw/git/2019/ipfs/orbit-web/node_modules/gc-stats/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:106:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:850:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
node-pre-gyp ERR! System Darwin 17.7.0
node-pre-gyp ERR! command "/usr/local/bin/node" "/Users/waterw/git/2019/ipfs/orbit-web/node_modules/gc-stats/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/waterw/git/2019/ipfs/orbit-web/node_modules/gc-stats
node-pre-gyp ERR! node -v v6.0.0
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok 
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/waterw/git/2019/ipfs/orbit-web/node_modules/gc-stats/build/gcstats/v1.2.1/Release/node-v48-darwin-x64/gcstats.node --module_name=gcstats --module_path=/Users/waterw/git/2019/ipfs/orbit-web/node_modules/gc-stats/build/gcstats/v1.2.1/Release/node-v48-darwin-x64 --node_abi_napi=node-v48 --napi_build_version=0 --node_napi_label=node-v48' (1)

解决方法

Mac升级到High sierra 后,发现执行使用npm 或者yarn 的时候,不时会报gyp: No Xcode or CLT version detected! 的错误, 原因是缺了xcode 的CLI 工具, 只要执行下面的命令来安装就可以了。

sudo xcode-select --install
 

你可能感兴趣的:(node-pre-gyp ERR! build error node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node)