Failed To compile

用户在 macOS 系统上通过 Zeabur 平台部署 LobeChat v2.2.9,执行 Docker 镜像构建时编译失败。浏览器为 Chrome,客户端类型为 Web (Desktop Browser)。

Failed To compile

Failed To compile

快速结论:该报错在 LobeChat v2.2.9 部署编译时触发,原因是 @lobehub/editor 依赖版本不匹配,新版移除了 FloatMenu 导出。优先排查 @lobehub/editor 的锁定版本。

问题场景

用户在 macOS 系统上通过 Zeabur 平台部署 LobeChat v2.2.9,执行 Docker 镜像构建时编译失败。浏览器为 Chrome,客户端类型为 Web (Desktop Browser)。

报错原文

INFO 🛠️ building image | #20 24.73 ╭─[ src/features/ChatInput/InputEditor/index.tsx:7:18 ]
INFO 🛠️ building image | #20 24.73 7 │ import { Editor, FloatMenu, useEditorState } from "@lobehub/editor/react";
INFO 🛠️ building image | #20 24.73 │                                    ────┬────
INFO 🛠️ building image | #20 24.73 │                                         ╰────── Missing export
ERROR INFO 🛠️ building image | #20 24.92  ELIFECYCLE  Command failed with exit code 1.
ERROR INFO 🛠️ building image | #20 24.94  ELIFECYCLE  Command failed with exit code 1.

原因分析

这是一个已知的依赖版本不匹配问题。在 LobeChat v2.2.9 中,src/features/ChatInput/InputEditor/index.tsx 仍然导入 FloatMenu,但 @lobehub/editor 的新版本(由 caret 范围 ^4.18.1 解析到的更高版本)已移除了 FloatMenu 的导出,导致编译时出现 “Missing export” 错误。

环境排查

  • LobeChat 版本:v2.2.9
  • 部署平台:Zeabur(Docker 构建)
  • 构建工具链:Vite + Rolldown
  • 相关依赖:@lobehub/editor(版本范围 ^4.18.1
  • 操作系统:macOS

解决步骤

  1. 确认是否为已知问题:该问题已在 PR #16566 和 PR #16438 中讨论,属于重构后引入的版本匹配问题。
  2. 可优先尝试:锁定 @lobehub/editor 到一个已知兼容的精确版本(例如 4.18.0),在项目的 package.json 中找到对应依赖项,将其版本从 ^4.18.1 改为 4.18.0
  3. 删除 node_modulespnpm-lock.yaml(或 package-lock.json / yarn.lock),重新执行安装和构建流程。
  4. 如果使用 Docker 构建,确保清除构建缓存后重新构建镜像。

验证方法

重新执行构建命令,观察编译过程不再出现 Missing export 错误,且构建成功退出码为 0,即可确认问题已解决。

参考来源

lobehub/lobe-chat #16568

celebrityanime
celebrityanime
文章: 11089

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注