#Openclaw Update, Invalid or Unexpected Token

1 messages · Page 1 of 1 (latest)

dim gulch
#
root@openclaw:~# openclaw update
Updating OpenClaw...

│
â—‡  âś— Updating via package manager (177ms)
    npm error Invalid or unexpected token
    npm error A complete log of this run can be found in: /root/.npm/_logs/2026-03-02T15_43_09_589Z-debug-0.log

Update Result: ERROR
  Root: /usr/lib/node_modules/openclaw
  Reason: global update
  Before: 2026.2.26
  After: 2026.2.26

Total time: 269ms
root@openclaw:~# 

Weird, how to fix?

jolly groveBOT
#

That npm error Invalid or unexpected token is almost always either:

  1. Node is too old for the JS syntax in the current npm/OpenClaw package, or
  2. Your npm install is corrupted (the log will show which file it choked on).

First, can you paste these outputs?

openclaw --version
node -v
npm -v
tail -n 80 /root/.npm/_logs/2026-03-02T15_43_09_589Z-debug-0.log

Key thing from the docs: OpenClaw requires Node >= 22 now.
So if node -v is < 22, upgrade Node first, then re-run the update. (Docs: https://docs.openclaw.ai/start/faq#what-runtime-do-i-need)

#

Quick workaround if Node is fine but npm is the thing that’s broken

Try updating via pnpm (often works even when npm is wedged):

corepack enable
corepack prepare pnpm@latest --activate
pnpm add -g openclaw@latest

Then:

openclaw doctor
openclaw gateway restart

Docs for the update flow: https://docs.openclaw.ai/install/updating and CLI details: https://docs.openclaw.ai/cli/update

#

If you paste the tail of that npm log, I can tell you immediately which of the two cases you’re in (old Node vs corrupted npm file) and the cleanest fix.

dim gulch
#

root@openclaw:~# openclaw --version
node -v
npm -v
tail -n 80 /root/.npm/_logs/2026-03-02T15_43_09_589Z-debug-0.log
2026.2.26
v22.22.0
10.9.4
0 verbose cli /usr/bin/node /usr/bin/npm
11 verbose stack /usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/can-place-dep.js:384
11 verbose stack ďż˝ // always place peers in preferDedupe mode
11 verbose stack
11 verbose stack
11 verbose stack SyntaxError: Invalid or unexpected token
11 verbose stack at wrapSafe (node:internal/modules/cjs/loader:1638:18)
11 verbose stack at Module._compile (node:internal/modules/cjs/loader:1680:20)
11 verbose stack at Object..js (node:internal/modules/cjs/loader:1839:10)
11 verbose stack at Module.load (node:internal/modules/cjs/loader:1441:32)
11 verbose stack at Function._load (node:internal/modules/cjs/loader:1263:12)
11 verbose stack at TracingChannel.traceSync (node:diagnostics_channel:328:14)
11 verbose stack at wrapModuleLoad (node:internal/modules/cjs/loader:237:24)
11 verbose stack at Module.require (node:internal/modules/cjs/loader:1463:12)
11 verbose stack at require (node:internal/modules/helpers:147:16)
11 verbose stack at Object.<anonymous> (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:21:5)
12 error Invalid or unexpected token
13 verbose cwd /usr/lib/node_modules/openclaw
14 verbose os Linux 6.17.4-2-pve
15 verbose node v22.22.0
16 verbose npm v10.9.4

[...]
Telegram: ok (@mysuperniceclawybot) (88ms)
Discord: not configured
Agents: main (default)
Heartbeat interval: 30m (main)
Session store (main): /root/.openclaw/agents/main/sessions/sessions.json (4 entries)

  • agent:main:main (16m ago)
  • agent:main:telegram:slash:8058418910 (17m ago)
  • agent:main:cron:baab57b6-a402-4060-8ae3-3c6dbc5fb8e1 (167m ago)
  • agent:main:cron:baab57b6-a402-4060-8ae3-3c6dbc5fb8e1:run:7f9a40f9-0d9c-4400-b629-3e4f93d51ba2 (167m ago)

root@openclaw:~#

jolly groveBOT
#

Your Node version is fine (v22.22.0). The stack trace shows npm itself is broken/corrupted:

  • It’s crashing while parsing its own file:
    /usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/can-place-dep.js:384
  • And the log even shows a weird replacement character ďż˝ on that line → that’s classic “file got corrupted / bad bytes on disk”.

So this isn’t an OpenClaw bug — openclaw update is just calling /usr/bin/npm, and npm can’t run.

1) Confirm the corruption (optional but useful)

nl -ba /usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/can-place-dep.js | sed -n '375,390p'

If you see that ďż˝ in the file output, yep.

2) Fix: reinstall Node/npm (Debian/Ubuntu/Proxmox apt)

On Proxmox/Debian this is usually enough:

#
apt-get update
apt-get install --reinstall -y nodejs
# if you have a separate npm package on your distro:
apt-get install --reinstall -y npm

Then verify:

node -v
npm -v
npm help >/dev/null

3) Re-run the update

#
openclaw update
# or directly:
npm i -g openclaw@latest

Then:

openclaw doctor
openclaw gateway restart

If apt reinstall doesn’t replace npm (rare)

Tell me what this prints and I’ll point you at the right package source:

which node
#
which npm
dpkg -S /usr/bin/npm || true
dpkg -S /usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/can-place-dep.js || true

Docs reference for the intended update paths: https://docs.openclaw.ai/install/updating

dim gulch
#

mandb: can't create index cache /var/cache/man/2162: Resource temporarily unavailable
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Solving dependencies... Error!
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
npm : Depends: node-agent-base but it is not going to be installed
Depends: node-archy but it is not going to be installed
Depends: node-cacache (>= 17) but it is not going to be installed
Depends: node-chalk (>= 5.1.2-2~) but it is not going to be installed
Depends: node-cli-table3

Weird

jolly groveBOT
#

That dependency error is because you tried to install Debian’s npm package (which pulls a ton of node-* deps). You don’t need that, and on minimal/proxmox-ish installs it often won’t resolve.

Your actual problem is simpler: the npm that’s already on the box is corrupted. The log shows npm parsing its own file and hitting a bad byte (�):

/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/can-place-dep.js:384

So: reinstall the nodejs package you’re using (NodeSource/etc.), which re-lays down npm.

Try this (and don’t install the npm apt package):

apt-get update
apt-get install --reinstall -y nodejs
node -v
npm -v
npm help >/dev/null
#

Then retry:

openclaw update

If apt-get install --reinstall nodejs doesn’t actually touch /usr/lib/node_modules/npm/, paste these and I’ll tell you the correct repo/package owner:

which node; which npm
dpkg -S /usr/bin/node /usr/bin/npm /usr/lib/node_modules/npm 2>/dev/null || true
apt-cache policy nodejs

(That mandb: can't create index cache ... line is annoying but usually harmless; it’s not the root cause of the npm syntax error.)

dim gulch
#

Ye thx that resolved it

jolly groveBOT
#

Nice — so it really was a corrupted npm install.

If you want to sanity-check everything is clean now:

npm help >/dev/null
openclaw update
openclaw doctor
openclaw gateway restart

Glad that helped. If this fixed it, please right-click the solution message → Apps → ✅ Mark Solution so Answer Overflow can index it for the next person.