openclaw - 💡(How to fix) Fix Bun: Cannot find module './dist/warning-filter.js' — isDirectModuleNotFoundError does not match Bun error format

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

When running openclaw under Bun, startup fails with:

error: Cannot find module './dist/warning-filter.js' from '/home/.../.bun/install/global/node_modules/openclaw/openclaw.mjs'

After adding a symlink for .js, it fails again on .mjs.

Error Message

error: Cannot find module './dist/warning-filter.js' from '/home/.../.bun/install/global/node_modules/openclaw/openclaw.mjs'

Root Cause

openclaw.mjs tries to import ./dist/warning-filter.js then ./dist/warning-filter.mjs and is designed to silently skip both if absent (installProcessWarningFilter, ~line 273). The guard isDirectModuleNotFoundError (~line 253) checks:

err.code === "ERR_MODULE_NOT_FOUND"

Bun does not set code: "ERR_MODULE_NOT_FOUND" on its module-resolution errors, so the check returns false, the error is re-thrown, and the process exits.

Additionally, the built dist/ only ships content-hashed filenames (e.g. warning-filter-Ek98bF5R.js) — no stable warning-filter.js / warning-filter.mjs — so the imports will always miss on a fresh install.

Fix Action

Workaround

cd ~/.bun/install/global/node_modules/openclaw/dist
ln -s warning-filter-*.js warning-filter.js
ln -s warning-filter-*.js warning-filter.mjs

Code Example

error: Cannot find module './dist/warning-filter.js' from '/home/.../.bun/install/global/node_modules/openclaw/openclaw.mjs'

---

err.code === "ERR_MODULE_NOT_FOUND"

---

cd ~/.bun/install/global/node_modules/openclaw/dist
ln -s warning-filter-*.js warning-filter.js
ln -s warning-filter-*.js warning-filter.mjs

---

message.includes(`Cannot find module '${specifier}'`) ||
message.includes(`Cannot find module "${specifier}"`)
RAW_BUFFERClick to expand / collapse

Summary

When running openclaw under Bun, startup fails with:

error: Cannot find module './dist/warning-filter.js' from '/home/.../.bun/install/global/node_modules/openclaw/openclaw.mjs'

After adding a symlink for .js, it fails again on .mjs.

Root cause

openclaw.mjs tries to import ./dist/warning-filter.js then ./dist/warning-filter.mjs and is designed to silently skip both if absent (installProcessWarningFilter, ~line 273). The guard isDirectModuleNotFoundError (~line 253) checks:

err.code === "ERR_MODULE_NOT_FOUND"

Bun does not set code: "ERR_MODULE_NOT_FOUND" on its module-resolution errors, so the check returns false, the error is re-thrown, and the process exits.

Additionally, the built dist/ only ships content-hashed filenames (e.g. warning-filter-Ek98bF5R.js) — no stable warning-filter.js / warning-filter.mjs — so the imports will always miss on a fresh install.

Workaround

cd ~/.bun/install/global/node_modules/openclaw/dist
ln -s warning-filter-*.js warning-filter.js
ln -s warning-filter-*.js warning-filter.mjs

Suggested fixes

Option 1 — extend isDirectModuleNotFoundError to handle Bun's error format. The message-based fallback already exists but uses fileURLToPath() which produces an absolute path that doesn't match the shorter relative path in Bun's message. Add a check on the raw specifier:

message.includes(`Cannot find module '${specifier}'`) ||
message.includes(`Cannot find module "${specifier}"`)

Option 2 — emit stable (unhashed) warning-filter.js / warning-filter.mjs at build time alongside the hashed files, so the imports resolve without symlinks.

Environment

  • Bun v1.3.13 (Linux x64)
  • openclaw 2026.5.22
  • Linux 7.0.0-15-generic

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING