Node + tsx 潰潰
Node + tsx “__name is not a function” 潰潰
Section titled “Node + tsx “__name is not a function” 潰潰”透過 Node 使用 tsx 執行 OpenClaw 時,在啟動時失敗並顯示:
[openclaw] 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
- OS:macOS(在其他執行 Node 25 的平台上也可能重現)
重現步驟(僅限 Node)
Section titled “重現步驟(僅限 Node)”# in repo rootnode --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 路徑),
openclaw status和gateway:watch運作正常。
-
使用 Bun 執行開發腳本(目前暫時回退)。
-
使用 Node + tsc watch,然後執行編譯輸出:
Terminal window pnpm exec tsc --watch --preserveWatchOutputnode --watch openclaw.mjs status -
已在本地確認:
pnpm exec tsc -p tsconfig.json+node openclaw.mjs status可在 Node 25 上運作。 -
如果可能的話,在 TS 載入器中停用 esbuild keepNames(這可以防止插入
__name輔助函數);tsx 目前未公開此選項。 -
使用
tsx測試 Node LTS (22/24),以查看問題是否僅限於 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 的回歸問題。
- 測試
tsx每夜版,如果存在已知的回歸問題,請固定到較早的版本。 - 如果在 Node LTS 上重現,請向上遊提交帶有
__name堆疊追蹤的最小重現案例。