npm install报错,gyp verb `which` failed Error: not found: python

主要错误

gyp verb which failed Error: not found: python2
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
npm ERR! node-sass@4.14.1 postinstall: node scripts/build.js

全部错误

bash 复制代码
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed     at getNotFoundError (D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\which\which.js:80:29)
gyp verb `which` failed     at D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\which\which.js:89:16
gyp verb `which` failed     at D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:158:21)
gyp verb `which` failed  python2 Error: not found: python2
gyp verb `which` failed     at getNotFoundError (D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\which\which.js:80:29)
gyp verb `which` failed     at D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\which\which.js:89:16
gyp verb `which` failed     at D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:158:21) {
gyp verb `which` failed   stack: 'Error: not found: python2\n' +
gyp verb `which` failed     '    at getNotFoundError (D:\\small software\\developer\\OpenSourceProjects\\book-v2.0\\sq-ui\\node_modules\\which\\which.js:13:12)\n' +
gyp verb `which` failed     '    at F (D:\\small software\\developer\\OpenSourceProjects\\book-v2.0\\sq-ui\\node_modules\\which\\which.js:68:19)\n' +
gyp verb `which` failed     '    at E (D:\\small software\\developer\\OpenSourceProjects\\book-v2.0\\sq-ui\\node_modules\\which\\which.js:80:29)\n' +
gyp verb `which` failed     '    at D:\\small software\\developer\\OpenSourceProjects\\book-v2.0\\sq-ui\\node_modules\\which\\which.js:89:16\n' +
gyp verb `which` failed     '    at D:\\small software\\developer\\OpenSourceProjects\\book-v2.0\\sq-ui\\node_modules\\isexe\\index.js:42:5\n' +
gyp verb `which` failed     '    at D:\\small software\\developer\\OpenSourceProjects\\book-v2.0\\sq-ui\\node_modules\\isexe\\windows.js:36:5\n' +
gyp verb `which` failed     '    at FSReqCallback.oncomplete (fs.js:158:21)',
gyp verb `which` failed   code: 'ENOENT'
gyp verb `which` failed }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` failed Error: not found: python
gyp verb `which` failed     at getNotFoundError (D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\which\which.js:80:29)
gyp verb `which` failed     at D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\which\which.js:89:16
gyp verb `which` failed     at D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:158:21)
gyp verb `which` failed  python Error: not found: python
gyp verb `which` failed     at getNotFoundError (D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\which\which.js:80:29)
gyp verb `which` failed     at D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\which\which.js:89:16
gyp verb `which` failed     at D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:158:21) {
gyp verb `which` failed   stack: 'Error: not found: python\n' +
gyp verb `which` failed     '    at getNotFoundError (D:\\small software\\developer\\OpenSourceProjects\\book-v2.0\\sq-ui\\node_modules\\which\\which.js:13:12)\n' +
gyp verb `which` failed     '    at F (D:\\small software\\developer\\OpenSourceProjects\\book-v2.0\\sq-ui\\node_modules\\which\\which.js:68:19)\n' +
gyp verb `which` failed     '    at E (D:\\small software\\developer\\OpenSourceProjects\\book-v2.0\\sq-ui\\node_modules\\which\\which.js:80:29)\n' +
gyp verb `which` failed     '    at D:\\small software\\developer\\OpenSourceProjects\\book-v2.0\\sq-ui\\node_modules\\which\\which.js:89:16\n' +
gyp verb `which` failed     '    at D:\\small software\\developer\\OpenSourceProjects\\book-v2.0\\sq-ui\\node_modules\\isexe\\index.js:42:5\n' +
gyp verb `which` failed     '    at D:\\small software\\developer\\OpenSourceProjects\\book-v2.0\\sq-ui\\node_modules\\isexe\\windows.js:36:5\n' +
gyp verb `which` failed     '    at FSReqCallback.oncomplete (fs.js:158:21)',
gyp verb `which` failed   code: 'ENOENT'
gyp verb `which` failed }
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 (D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\node-gyp\lib\configure.js:484:19)
gyp ERR! stack     at PythonFinder.<anonymous> (D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\node-gyp\lib\configure.js:509:16)
gyp ERR! stack     at callback (D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\graceful-fs\polyfills.js:306:20)
gyp ERR! stack     at FSReqCallback.oncomplete (fs.js:158:21)
gyp ERR! System Windows_NT 10.0.22631
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\small software\\developer\\OpenSourceProjects\\book-v2.0\\sq-ui\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\node-sass
gyp ERR! node -v v12.13.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@~2.3.2 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules\watchpack-chokidar2\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules\webpack-dev-server\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN sass-loader@10.1.0 requires a peer of sass@^1.3.0 but none is installed. You must install peer dependencies yourself.
npm WARN sass-loader@10.1.0 requires a peer of fibers@>= 3.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-loader@2.2.1 requires a peer of eslint@>=1.6.0 <7.0.0 but none is installed. You must install peer dependencies yourself.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.14.1 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.14.1 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\sy-sqw\AppData\Roaming\npm-cache\_logs\2024-09-15T08_49_59_575Z-debug.log

解决:

node-sass 问题

node-sass版本需与node版本对应,如下

可在项目根目录文件package.json中查看node-sass版本,没有请忽略

bash 复制代码
  "devDependencies": {
    "node-sass": "4.14.1",
    "sass-loader": "10.1.0"
  },

设置镜像

bash 复制代码
// 设置国内npm镜像地址
npm config set registry http://registry.npmmirror.com
// 查询npm配置
npm config list

安装编译环境

bash 复制代码
npm install -g node-gyp
// 在 Windows 上?想要编译原生 Node 模块吗?使用这一行安装构建工具。以管理员身份启动 PowerShell 并运行
npm install --global --production windows-build-tools

https://www.npmjs.com/package/windows-build-tools

卸载安装失败的包,重新安装

bash 复制代码
npm uninstall node-sass
npm install sass -i

最后

bash 复制代码
npm install
相关推荐
博客zhu虎康6 分钟前
ElementUI 的 form 表单校验
前端·javascript·elementui
咸鱼桨10 分钟前
《庐山派从入门到...》PWM板载蜂鸣器
人工智能·windows·python·k230·庐山派
yusaisai大鱼25 分钟前
tensorflow_probability与tensorflow版本依赖关系
人工智能·python·tensorflow
Biomamba生信基地29 分钟前
R语言基础| 功效分析
开发语言·python·r语言·医药
敲啊敲952734 分钟前
5.npm包
前端·npm·node.js
CodeClimb44 分钟前
【华为OD-E卷-木板 100分(python、java、c++、js、c)】
java·javascript·c++·python·华为od
brrdg_sefg1 小时前
Rust 在前端基建中的使用
前端·rust·状态模式
夜幕龙1 小时前
iDP3复现代码数据预处理全流程(二)——vis_dataset.py
人工智能·python·机器人
m0_748230941 小时前
Rust赋能前端: 纯血前端将 Table 导出 Excel
前端·rust·excel
qq_589568101 小时前
Echarts的高级使用,动画,交互api
前端·javascript·echarts