npm i安装包依赖时 gyp ERR! stack Error: Can‘t find Python executable “python“, you can set the PYTHON env
报错内容
gyp verb ensuring that file exists: C:\Python27\python.exe
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp verb could not find "python". checking python launcher
gyp verb could not find "python". guessing location
gyp verb ensuring that file exists: C:\Python27\python.exe
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack at PythonFinder.failNoPython (E:\code\mydyh\vue-admin-pro-master\node_modules\node-gyp\lib\configure.js:484:19)
gyp ERR! stack at PythonFinder.<anonymous> (E:\code\mydyh\vue-admin-pro-master\node_modules\node-gyp\lib\configure.js:509:16)
gyp ERR! stack at callback (E:\code\mydyh\vue-admin-pro-master\node_modules\graceful-fs\polyfills.js:289:20)
gyp ERR! stack at FSReqCallback.oncomplete (fs.js:183:21)
gyp ERR! System Windows_NT 10.0.19042
gyp ERR! command "D:\\ProgramFiles\\nodejs\\node.exe" "E:\\code\\mydyh\\vue-admin-pro-master\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd E:\code\mydyh\vue-admin-pro-master\node_modules\node-sass
gyp ERR! node -v v14.16.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.12.0 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.12.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\user\AppData\Roaming\npm-cache\_logs\2021-05-13T10_26_43_202Z-debug.log
解决
方式一:安装python解决(正确配置系统环境变量),python(v2.7 recommended, v3.x.x is not supported) - 推荐
下载:http://www.python.org/ftp/python/2.7.3/python-2.7.3.msi自行下载
npm install --python=python2.7 #先下载
npm config set python python2.7 #再设置环境
方式二:先用管理员身份打开cmd - 推荐
清除npm缓存 npm cache clean --force
1.安装 npm install -g node-gyp
2.安装 npm install --global --production windows-build-tools
-报错加版本号
2.1 npm install --global --production windows-build-tools@4.0.0
默认安装路径
npm install --python=python2.7
npm config set python python2.7
如果不是默认安装
需要指定python位置:
npm config set python phthon安装路径
如npm config set python 'D:/python/python.exe'
.windows-build-tools文件夹中多了一些东西
解决
①执行npm命令npm install --global --production windows-build-tools@4.0.0
②当命令行界面开始不动时,打开任务管理器,把Build Tools结束任务(因为我没有找到BuildTolls_Full.exe)。
③再打开.windows-build-tools文件夹中的build-tools-log.txt,添加Variable: IsInstalled = 1,保存,关闭。
再看PowerShell界面
本文来自博客园,作者:JackieDYH,转载请注明原文链接:https://www.cnblogs.com/JackieDYH/p/17634283.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY