Error: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found

Vite在Linux环境中构建react项目失败

本地没问题, 发布测试环境有问题, 详细错误信息如下

shell 复制代码
`[17:05:58] > tsc -b && vite build`

`[17:05:58] `

`[17:06:03] /root/workspace/project/node_modules/.pnpm/rollup@4.47.0/node_modules/rollup/dist/native.js:64`

`[17:06:03]  throw new Error(`

`[17:06:03]        ^`

`[17:06:03] `

``[17:06:03] Error: Cannot find module @rollup/rollup-linux-x64-gnu. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try `npm i` again after removing both package-lock.json and node_modules directory.``

`[17:06:03]     at requireWithFriendlyError (/root/workspace/project/node_modules/.pnpm/rollup@4.47.0/node_modules/rollup/dist/native.js:64:9)`

`[17:06:03]     at Object.<anonymous> (/root/workspace/project/node_modules/.pnpm/rollup@4.47.0/node_modules/rollup/dist/native.js:73:76)`

`[17:06:03]     at Module._compile (node:internal/modules/cjs/loader:1554:14)`

`[17:06:03]     at Object..js (node:internal/modules/cjs/loader:1706:10)`

`[17:06:03]     at Module.load (node:internal/modules/cjs/loader:1289:32)`

`[17:06:03]     ... 2 lines matching cause stack trace ...`

`[17:06:03]     at wrapModuleLoad (node:internal/modules/cjs/loader:220:24)`

`[17:06:03]     at cjsLoader (node:internal/modules/esm/translators:262:5)`

`[17:06:03]     at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:196:7) {`

``[17:06:03]   [cause]: Error: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /root/workspace/project/node_modules/.pnpm/@rollup+rollup-linux-x64-gnu@4.47.0/node_modules/@rollup/rollup-linux-x64-gnu/rollup.linux-x64-gnu.node)``

`[17:06:03]       at Object..node (node:internal/modules/cjs/loader:1732:18)`

`[17:06:03]       at Module.load (node:internal/modules/cjs/loader:1289:32)`

`[17:06:03]       at Function._load (node:internal/modules/cjs/loader:1108:12)`

`[17:06:03]       at TracingChannel.traceSync (node:diagnostics_channel:322:14)`

`[17:06:03]       at wrapModuleLoad (node:internal/modules/cjs/loader:220:24)`

`[17:06:03]       at Module.require (node:internal/modules/cjs/loader:1311:12)`

`[17:06:03]       at require (node:internal/modules/helpers:136:16)`

`[17:06:03]       at requireWithFriendlyError (/root/workspace/project/node_modules/.pnpm/rollup@4.47.0/node_modules/rollup/dist/native.js:46:10)`

`[17:06:03]       at Object.<anonymous> (/root/workspace/project/node_modules/.pnpm/rollup@4.47.0/node_modules/rollup/dist/native.js:73:76)`

`[17:06:03]       at Module._compile (node:internal/modules/cjs/loader:1554:14) {`

`[17:06:03]     code: 'ERR_DLOPEN_FAILED'`

`[17:06:03]   }`

`[17:06:03] }`

`[17:06:03] `

`[17:06:03] Node.js v22.14.0`

`[17:06:03]  ELIFECYCLE  Command failed with exit code 1.`

大致意思就是GLIBC_2.32, 找不到对应的 @rollup/rollup-linux-x64-gnu. 这个包,导致报错

先说解决方案

1、在package.json中加入如下代码

json 复制代码
  "optionalDependencies": {
    "@rollup/rollup-linux-x64-gnu": "*"
  }

2、如果使用pnpm或者其他包安装工具, 重新install 一下更新一下lock文件即可

注意⚠️

如果不重新install, lock文件不更新还是会导致安装失败哦

写在最后

如果大家有更好的解决方案, 欢迎大家留言哦!

相关推荐
开开心心就好3 小时前
批量提取PDF中的图片,直接导出原图
前端·javascript·支持向量机·智能手机·pdf·html·启发式算法
Setsuna_F_Seiei5 小时前
前端转型 Agent 开发 05 之 Agent Hooks 与 Checkpointer(让 Agent 从全自动转变人为可掌控)
前端·agent·ai编程
百万蹄蹄向前冲7 小时前
风扇转了一晚上MVP专家团翻车事故
前端·人工智能
默_笙7 小时前
🏛 给 AI 配一间办公室:Harness Engineering 六大模块与它的实现
前端·javascript
linux_cfan8 小时前
videojs v10 源代码系列解读:14 · 谓词守卫:在运行时安全地调用能力
前端·javascript·音视频
kyriewen8 小时前
我扒了 10,221 条 JD:腾讯技术岗 75% 在要 AI
前端·人工智能·ai编程
郑州光合科技余经理9 小时前
同城外卖小程序开发:下单成功后,后台导出能不能对上用户端状态
开发语言·前端·git·后端·uni-app·php·ai编程
IT_陈寒10 小时前
Vue的响应式让我熬到凌晨三点,原来漏了这个小细节
前端·人工智能·后端
Blanche150010 小时前
利用 RAG 为答疑机器人扩展知识范围
前端
天若有情67310 小时前
【纯前端小工具】公历生日转农历,批量查询每年农历生日对应的公历日期(GitHub Pages在线直接用)
前端·javascript·github pages·农历转换·lunisolar·网页小工具