gyp ERR!与node-pre-gyp ERR!

问题:同事写的一个vue项目在我的电脑上运行npm install时报错:

gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/xxx/xxx/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Darwin 17.7.0
gyp ERR! command "/usr/local/bin/node" "/Users/xxx/xxx/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/xxx/xxx/node_modules/node-sass
gyp ERR! node -v v12.18.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 

问题出在node-gyp上,但是网上的答案试了几个(
1、重新安装node-gyp、
2、重新设置权限用户sudo npm install --unsafe-perm、
3、重新设置 Xcode的路径sudo xcode-select -s /Applications/Xcode.app/Contents/Developer)都没能解决


解决方案:问题还是出在node和node-gyp版本不兼容上,可以用升降node版本来解决。我的mac系统较老,选择了降node版本v11.10.0

你可能感兴趣的:(node.jsnpm)