Skip to content

Fixing the Node + tsx "__name is not a function" Crash

I’ve been there—you switch a dev script to make your project more accessible to others, and suddenly everything breaks with a error you’ve never seen before. It is frustrating when a tool that is supposed to help ends up blocking your workflow.

I recently ran into this while moving away from one runtime to gain more flexibility. It reminded me how tricky loaders can be when they interact with specific Node versions. If you are seeing a crash at startup, here is how to handle it.

  • Node.js (v22 or v25)
  • tsx (v4.21.0)
  • pnpm
  • OpenClaw source code

If you want to reproduce the issue or check if your environment is affected, follow these four steps.

  1. Check your version: Run node --version to ensure you are on a version like v25.3.0 or v22.22.0.
  2. Install dependencies: Run pnpm install in the repo root.
  3. Run the entry point: Execute node --import tsx src/entry.ts status.
  4. Run the minimal repro: Use node --import tsx scripts/repro/tsx-name-repro.ts to confirm the crash.

The crash usually shows up as TypeError: __name is not a function inside your logs. This happens because tsx uses esbuild to transform code, and esbuild’s keepNames feature emits a __name helper. In certain Node loader paths, this helper is missing or overwritten.

I recommend trying these four workarounds to get back to work.

If you need to move fast, revert to using Bun for your dev scripts. This was the path used before the change in commit 2871657e and is known to work.

You can avoid the tsx loader issue by compiling with tsc first and then running the output with Node.

Terminal window
pnpm exec tsc --watch --preserveWatchOutput
node --watch openclaw.mjs status

If you don’t need a watcher, you can manually compile and run the generated file.

Terminal window
pnpm exec tsc -p tsconfig.json
node openclaw.mjs status

The issue is observed on Node 25.3.0 and 22.22.0. I suggest testing with other Node LTS releases to see if the loader behavior changes.

If you still have questions about your specific environment, check the AI Setup Assistant.

OpenClaw

OpenClaw Expert

Still stuck?

If this page didn't answer your case, ask OpenClaw Expert for step-by-step guidance.