Node + tsx 崩溃
Node + tsx “__name is not a function” 崩溃
Section titled “Node + tsx “__name is not a function” 崩溃”通过 Node 使用 tsx 运行 CoderClaw 时,启动阶段报错:
[coderclaw] Failed to start CLI: TypeError: __name is not a function at createSubsystemLogger (.../src/logging/subsystem.ts:203:25) at .../src/agents/auth-profiles/constants.ts:25:20此问题在开发脚本从 Bun 切换到 tsx 后出现(提交 2871657e,2026-01-06)。相同的运行路径在 Bun 下正常工作。
- Node: v25.x(在 v25.3.0 上观察到)
- tsx: 4.21.0
- 操作系统: macOS(其他运行 Node 25 的平台也可能复现)
复现步骤(仅 Node)
Section titled “复现步骤(仅 Node)”# 在仓库根目录node --versionpnpm installnode --import tsx src/entry.ts status仓库内最小复现
Section titled “仓库内最小复现”node --import tsx scripts/repro/tsx-name-repro.tsNode 版本检查
Section titled “Node 版本检查”- Node 25.3.0:失败
- Node 22.22.0(Homebrew
node@22):失败 - Node 24:尚未安装,需要验证
说明 / 假设
Section titled “说明 / 假设”tsx使用 esbuild 转换 TS/ESM。esbuild 的keepNames会生成一个__name辅助函数,并用__name(...)包裹函数定义。- 崩溃表明
__name存在但在运行时不是函数,这意味着在 Node 25 的加载器路径中该辅助函数缺失或被覆盖。 - 其他 esbuild 使用者也报告过类似的
__name辅助函数缺失或被重写的问题。
2871657e(2026-01-06):脚本从 Bun 改为 tsx,使 Bun 成为可选项。- 在此之前(Bun 路径),
coderclaw status和gateway:watch均正常工作。
- 开发脚本使用 Bun(当前临时回退方案)。
- 使用 Node + tsc watch,然后运行编译产物:
Terminal window pnpm exec tsc --watch --preserveWatchOutputnode --watch coderclaw.mjs status - 已在本地确认:
pnpm exec tsc -p tsconfig.json+node coderclaw.mjs status在 Node 25 上可正常运行。 - 如果可能,在 TS 加载器中禁用 esbuild 的 keepNames(防止插入
__name辅助函数);tsx 目前不提供此配置项。 - 在 Node LTS(22/24)上测试
tsx,确认该问题是否为 Node 25 特有。
- https://opennext.js.org/cloudflare/howtos/keep_names
- https://esbuild.github.io/api/#keep-names
- https://github.com/evanw/esbuild/issues/1031
- 在 Node 22/24 上复现,确认是否为 Node 25 回归问题。
- 测试
tsxnightly 版本,或在存在已知回归时固定到早期版本。 - 如果在 Node LTS 上也能复现,则向上游提交包含
__name堆栈跟踪的最小复现。