Why does npm run build fail on Ubuntu with Node.js?

In short: `npm run build` fails with a stack of dependency errors — not a Hermes Agent bug, a Node.js version mismatch. Under Node 18 and Node 20 (the default LTS on most recent WSL2 images), the build fails consistently; under Node 22, it succeeds in 52 seconds, no other change. On Ubuntu 20.04 it's worse: `apt install nodejs` still installs Node 10.x.

The symptom is always the same: `npm install` runs clean, then `npm run build` stops with a stack of messages about dependencies expecting a newer API. Nothing exotic — this isn't a broken install, it's a Node.js version mismatch.

We reproduced the error, changed only the Node version, and reran it: consistent failure under Node 18 and Node 20 (the default LTS on most recent WSL2 images), immediate success under Node 22 — 52 seconds to build, no other change.

On Ubuntu 20.04 specifically, the starting point is even further off: `apt install nodejs` installs Node 10.x, a version the official Ubuntu repository has never kept in step with actual Node releases — far too old for most current JavaScript projects, not just Hermes Agent.

With `nvm` already installed, switching versions takes ten seconds:

``` nvm install 22 nvm use 22 npm run build ```

Without `nvm`, expect more like fifteen minutes to cleanly install a recent Node version on Ubuntu, including the time to set up the NodeSource repository:

``` curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - sudo apt-get install -y nodejs node -v ```

If you'd rather not manage the server or its updates at all, [we host it for you](https://hermesagentfrance.com/en/hermes-hosted): you keep your own API key, €12/month flat, nothing else to configure.

→ See the 6 pitfalls that cost half a day