npm install时报错gyp ERR! stack Error: Can't find Python executable "2.7"

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了npm install时报错gyp ERR! stack Error: Can't find Python executable "2.7"相关的知识,希望对你有一定的参考价值。

参考技术A 环境:windows10

具体报错信息如下

我的主要搜索目标是在python2.7找不到这个信息上,根据网上各种帖子尝试都没成功,

最后一次搜索是搜索的node-sass错误

最终在这个贴子找到了答案,被墙了,很多时候,可能真的需要换个方向,emmm,头铁啊老铁

或者

记录一下
https://segmentfault.com/a/1190000010984731?utm_source=tag-newest

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

以上是关于npm install时报错gyp ERR! stack Error: Can't find Python executable "2.7"的主要内容,如果未能解决你的问题,请参考以下文章

npm install 时报错npm ERR! Windows_NT 6.1.7601

npm install时报错 npm ERR!Windows_NT 6.1.7601

npm install 在 react-native 中出现错误“gyp ERR!find VS”

npm 安装模块报node-gyp ERR!

gyp ERR find Python 解决方案

gyp ERR!与node-pre-gyp ERR!