天天看點

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