npm i安装包依赖时 gyp ERR! stack Error: Can‘t find Python executable “python“, you can set the PYTHON env
Posted JackieDYH
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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界面
以上是关于npm i安装包依赖时 gyp ERR! stack Error: Can‘t find Python executable “python“, you can set the PYTHON env的主要内容,如果未能解决你的问题,请参考以下文章