从 Bun 生态彻底移植到 Node.js 22,服务器 8099 端口稳定运行,返回完整 HTML 文档 ✅
node:sqlite, fs, path 等.lengthfs 操作import.meta.filename + dirnamethrow Error("native not available")const registerBunPlugin = () => {}libopentui.so 路径instance.ts 顶层 makeRuntime() 调用,改为惰性初始化import.meta.dirname 替换为 Node.js 的 import.meta.filename + dirname,修正 src/migration 路径查找--> statement-breakpoint 分隔多条语句,需分割后逐条执行node:sqlite 的 db.run() 不支持多语句,需改为 $client.exec()
从 Bun 生态移植到 Node.js 的改造涉及了大量底层工作——@opentui/core 和 @opentui/core-linux-x64 等依赖深度依赖 Bun 的 bun:ffi、import...with{type:"file"}、top-level await 等特性,需要逐个 patch。数据库层也需要适配 node:sqlite 的 API 差异。
🔥 pnpm install 1293 包 ✅
🔥 20+ 处 bun:* 模块替换 ✅
🔥 14 张数据库表全部创建 ✅
🔥 服务器 HTTP 200 响应 ✅
最终服务器成功跑起来,Web 界面正常渲染 ✅
这是国内首个在 Node.js 上跑起来的 Opencode 发行版,摆脱了对 Bun 运行时的依赖。