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.
What You’ll Need
Section titled “What You’ll Need”- Node.js (v22 or v25)
- tsx (v4.21.0)
- pnpm
- OpenClaw source code
Quick Start
Section titled “Quick Start”If you want to reproduce the issue or check if your environment is affected, follow these four steps.
- Check your version: Run
node --versionto ensure you are on a version like v25.3.0 or v22.22.0. - Install dependencies: Run
pnpm installin the repo root. - Run the entry point: Execute
node --import tsx src/entry.ts status. - Run the minimal repro: Use
node --import tsx scripts/repro/tsx-name-repro.tsto confirm the crash.
Troubleshooting
Section titled “Troubleshooting”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.
1. Use Bun for dev scripts
Section titled “1. Use Bun for dev scripts”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.
2. Use tsc watch mode
Section titled “2. Use tsc watch mode”You can avoid the tsx loader issue by compiling with tsc first and then running the output with Node.
pnpm exec tsc --watch --preserveWatchOutputnode --watch openclaw.mjs status3. Manual compilation
Section titled “3. Manual compilation”If you don’t need a watcher, you can manually compile and run the generated file.
pnpm exec tsc -p tsconfig.jsonnode openclaw.mjs status4. Test Node LTS versions
Section titled “4. Test Node LTS versions”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.
What’s Next
Section titled “What’s Next”OpenClaw Expert
Still stuck?
If this page didn't answer your case, ask OpenClaw Expert for step-by-step guidance.