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
相关推荐
এ慕ོ冬℘゜5 分钟前
前端树形二级列表渲染 + 页面传参完整实战解析(附原生jQuery源码)
前端·javascript·jquery
事缓则圆17 分钟前
从零推导 Python 装饰器:不用背语法,看完这篇就懂了
python
鬼手点金19 分钟前
Hermes‑Agent 使用教程
python·ubuntu·powershell·cmd·ai agent·opencode·hermes
Gu Gu Study22 分钟前
【agent认知】宏观Agent的基本两层架构(Agent Loop与Agent Harness)
python·架构
从小就看凹凸曼^o^25 分钟前
Python基础3 - 流程控制语句:(1)程序结构
python
weixin_4692738135 分钟前
.md文件是什么?.md如何打开?
前端·编辑器
不好听61341 分钟前
Web Worker:浏览器给 JS 开的后台子线程
前端·浏览器
计算机魔术师1 小时前
数据分析还在靠人跑 SQL?AI 智能体已经把效率拉到 63 倍
前端
小陈的进阶之路1 小时前
爬虫三大解析库:lxml, jsonpath, bs4
开发语言·笔记·python
瑞码空间1 小时前
Routing & API:前后端协作的本质与实现
前端·后端·接口·路由