npm global install: OpenClaw breaks after upgrade/downgrade (missing dist chunk)
Fix OpenClaw global installs that break after a version swap (upgrade/downgrade) with errors like 'Cannot find module ... dist/...chunk...' by doing a clean reinstall and refreshing the gateway service install.
Symptoms
- After an
npm install -g openclaw@...upgrade or downgrade, OpenClaw becomes unusable. - Tool-heavy workflows break (TUI/agent/channel runs), often looking like “tools silently don’t work”.
- You see a runtime import error such as:
Cannot find module '.../openclaw/dist/...chunk....js'Cannot find module '.../tool-loop-detection-....js'
Cause
This is usually not a config problem. It’s a corrupted global package tree after a version swap:
- A previous build’s content-hashed dist chunk is still referenced somewhere, but the file is no longer present.
- A simple in-place overwrite (
npm install -g openclaw@other-version) can leave you in a half-upgraded state.
Fix
1) Use OpenClaw’s updater for normal updates
For a healthy install, prefer the updater instead of overwriting the global package tree:
openclaw update
openclaw gateway restart
As of June 2026, the stable release on npm latest is 2026.6.1. Beta/main can be newer; only target those channels intentionally.
2) If the install is already corrupted, clean reinstall the CLI/runtime
Do a full uninstall, then install the exact stable package you want.
Install latest cleanly:
npm uninstall -g openclaw
npm install -g openclaw@latest --force
Or pin a known-good version cleanly:
openclaw update --tag <last-working-version>
Why this helps: uninstall + reinstall forces npm to rebuild the global package tree from scratch instead of trying to reconcile two versions’ dist chunks.
3) Refresh the gateway service install (if you run as a service)
If you installed the gateway as a background service (launchd/systemd/Scheduled Task), refresh the service definition so it points at the current runtime:
openclaw gateway install --force
openclaw gateway restart
Why this helps: even after a clean npm reinstall, your service can still be running an older path/runtime until it is reinstalled.
4) Verify you didn’t accidentally keep multiple installs
If things still look inconsistent, confirm you’re running the binary you think you are:
which openclaw
openclaw --version
Verify
openclaw doctorruns without crashing.- Tool calls work again (for example: a small
exec,read, or config probe). openclaw gateway statusshows the expected service state.