天天看点

npm i安装包依赖时 gyp ERR! stack Error: Can‘t find

作者:未必顽固

报错内容

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: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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 [email protected]

默认安装路径npm install --python=python2.7npm config set python python2.7  如果不是默认安装需要指定python位置:npm config set python phthon安装路径如npm config set python 'D:/python/python.exe'           
npm i安装包依赖时 gyp ERR! stack Error: Can‘t find
.windows-build-tools文件夹中多了一些东西
npm i安装包依赖时 gyp ERR! stack Error: Can‘t find

解决

①执行npm命令npm install --global --production [email protected]

②当命令行界面开始不动时,打开任务管理器,把Build Tools结束任务(因为我没有找到BuildTolls_Full.exe)。

③再打开.windows-build-tools文件夹中的build-tools-log.txt,添加Variable: IsInstalled = 1,保存,关闭。

npm i安装包依赖时 gyp ERR! stack Error: Can‘t find
npm i安装包依赖时 gyp ERR! stack Error: Can‘t find

再看PowerShell界面

npm i安装包依赖时 gyp ERR! stack Error: Can‘t find