问题描述
使用 Node + tsx 运行 OpenClaw 时,启动报错:
[openclaw] Failed to start CLI: TypeError: __name is not a function
at createSubsystemLogger (.../src/logging/subsystem.ts:203:25)
环境
- Node:v25.x(v25.3.0 已确认)
- tsx:4.21.0
- 触发时间:2026-01-06 从 Bun 切换到 tsx 后(commit
2871657e)
复现步骤
node --import tsx src/entry.ts status
# 或最小复现:
node --import tsx scripts/repro/tsx-name-repro.ts根因分析
tsx 使用 esbuild 转换 TS/ESM,esbuild 的 keepNames 会注入 __name helper 并用 __name(...) 包装函数定义。崩溃表明在 Node 25 loader 路径中,该 helper 缺失或被覆盖。
临时解决方案
- 使用 Bun 运行开发脚本(当前临时回退方案)
- 使用构建产物:
pnpm tsgo node openclaw.mjs status - 测试 Node LTS(22/24)确认是否为 Node 25 特有问题
后续行动
- 在 Node 22/24 上复现以确认是否为 Node 25 回归
- 测试
tsx最新版或固定到已知正常版本 - 如在 Node LTS 上复现,向上游提交最小复现案例