GuidesGetting started

How to install nvm and Node.js on Ubuntu (for AI agents)

nvm v0.41.0's install line, nvm install --lts (Node 26.14), the Node each agent needs, and why cron, systemd and SSH commands can't find node under nvm.

December 2, 2026The Everpod team
The short answer

Install nvm as the user who will run your tools, not as root, with the line from its README (v0.41.0 is the current release, from November 4, 2026), open a new shell, then run nvm install --lts. As of December 2, 2026 that gives Node 26.14.0, the LTS line since October 28, which meets every npm-installed coding agent’s requirement, OpenClaw’s included. The catch on a server: nvm only exists in interactive shells of that one user, so a cron job, a systemd service or ssh host 'codex ...' finds no node and no agent until you give it the path.

Installing nvm

The installer is fetched with curl (or wget, with the README’s other line). It clones nvm into ~/.nvm and appends the lines that load it to your shell’s startup file, which for bash is ~/.bashrc. This is the command from the nvm README as of December 2026:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.41.0/install.sh | bash
Copied

The version is part of the URL, so a copy of this line from an older tutorial installs an older nvm; the releases page shows the newest. Running the line again later is also how nvm updates itself. When it finishes, the current shell does not know about nvm yet. Load it, or log out and back in:

source ~/.bashrc
command -v nvm
Copied

The second command prints nvm when it worked. which nvm does not find it even when nvm is fine, because nvm is a shell function, not a program on disk; that is the first hint of the trap further down.

Run all of this as the account your agent will run under. nvm puts everything in that account’s home: installed as root, it is in /root and your login user cannot see it.

Installing and switching Node versions

nvm install --lts
nvm install 24
nvm ls
nvm use 24
nvm alias default 'lts/*'
Copied

nvm install --lts fetches the newest long-term-support release; nvm install 24 the newest 24.x, and a full number such as 26.13.1 that exact one. nvm install node means the newest release of any line, LTS or not. The first version you install becomes the default for new shells; nvm use switches the current shell only, and nvm alias default changes what new shells get. An alias can name 'lts/*', the newest LTS, instead of a number.

Which lines are worth installing, from Node’s release schedule and the release index as of December 2, 2026:

LineNewestStatusSecurity fixes until
26 (Lithium)
26.14.0Active LTS since October 28, 2026April 30, 2029
24 (Krypton)
24.23.0Maintenance since October 20, 2026April 30, 2028
22 (Jod)
22.23.5MaintenanceApril 30, 2027
20 (Iron)
20.20.2EndedApril 30, 2026

Node 27 exists only as alpha builds; its first release is scheduled for April 2027. nvm v0.41.0 leaves alphas out of what it offers by default.

Which Node the agents need

Each agent’s npm package declares the Node it supports in its engines field. Read from the npm registry on December 2, 2026, for the latest release of each:

Agent (npm package)VersionNode it declares
OpenClaw (openclaw)
2026.12.1>=24.16.0 <25 || >=26.1.0
Pi (@earendil-works/pi-coding-agent)
1.7.0>=22.19.0
Claude Code (@anthropic-ai/claude-code)
2.1.334>=22.0.0
Gemini CLI (@google/gemini-cli)
0.72.0>=20
Codex (@openai/codex)
0.173.0>=16
OpenCode (opencode-ai)
1.19.6No range declared

Node 26 satisfies all of them, and so does 24 if it is 24.16 or later. OpenClaw is the strict one: its range is a minimum within each line, and some of its releases have asked for more, which the OpenClaw Node version guide tracks release by release. Check what a shell is using with node -v.

Pinning a project with .nvmrc

A file called .nvmrc holding a version tells nvm which Node a directory wants. With no version on the command line, nvm use, nvm install, nvm exec and nvm run read it, searching upward from the current directory:

echo "26" > .nvmrc
nvm install
nvm use
Copied

nvm answers with Found '/path/to/project/.nvmrc' with version <26>. It does not switch on its own when you change directory; the README has a hook for that, contributed by users and not supported by the maintainers. fnm, below, does it with a flag.

Global packages belong to one Node version

Under nvm, npm install -g installs into the active version’s own folder, ~/.nvm/versions/node/v26.14.0/, and its command lands in that version’s bin, so a global install needs no sudo. The cost: after nvm use 24, an agent installed under 26 is gone from your PATH, and after you install a new version it has no agents until you bring them across. Moving to the newest LTS and reinstalling everything from the version you are on is one command:

nvm install --reinstall-packages-from=current 'lts/*'
Copied

nvm reinstall-packages <version> does the same between two versions you already have, and package names listed one per line in ~/.nvm/default-packages are installed into every new version automatically. Agents that keep their settings in your home directory (~/.codex, ~/.openclaw and so on) keep them across versions; only the program moves.

Why cron, systemd and SSH commands cannot find node

nvm works by being loaded into an interactive shell, and three common ways of running an agent on a server do not start one:

Each ends in command not found, or in a service that starts and exits at once. Calling the agent by its full path is not enough on its own: Codex’s and Gemini CLI’s commands, like most npm CLIs, start with #!/usr/bin/env node, so they look for node on the PATH and fail the same way. What works is putting the version’s bin directory on the PATH. Find it from a normal shell:

nvm which current
Copied

That prints the active node, for example /home/you/.nvm/versions/node/v26.14.0/bin/node; the directory around it is the one you need. Then, by case:

For an SSH command, load nvm first in the same command. It picks up your default version:

ssh you@your-server '. ~/.nvm/nvm.sh && codex --version'
Copied

If you do this often, moving nvm’s lines in ~/.bashrc above the “not running interactively” block makes every SSH command load it.

For cron, set PATH at the top of the crontab (crontab -e), with your own home and version in place of the example:

PATH=/home/you/.nvm/versions/node/v26.14.0/bin:/usr/local/bin:/usr/bin:/bin
Copied

For a systemd service, give it the same PATH in the [Service] section, and a full path in ExecStart, here a script of yours that starts the agent; the script and everything it calls then find node:

Environment=PATH=/home/you/.nvm/versions/node/v26.14.0/bin:/usr/local/bin:/usr/bin:/bin
ExecStart=/home/you/bin/run-agent.sh
Copied

A user service like this one also needs lingering turned on, or it stops when you log out: see keeping a systemd user service running after logout. The version is written into every one of these lines, so switching Node under nvm means editing them; an upgrade that skips them leaves the job on the old version, or broken if you uninstalled it. For a machine whose agents run mostly from cron and services, that is the argument for a system-wide Node instead.

A system-wide Node instead: apt and NodeSource

A Node installed by the system package manager lives in /usr/bin, which cron, systemd and every user find without help. Ubuntu’s own nodejs package is the obvious choice and usually the wrong one for agents, because each Ubuntu release freezes its version (from packages.ubuntu.com, December 2, 2026):

Ubuntuapt’s nodejsEnough for
22.04
12.22.9None of the agents above
24.04
18.19.1Codex only
26.04
22.22.1Everything above except OpenClaw

NodeSource publishes current Node lines as apt packages. Its script adds the repository for one major line, after which apt installs and updates Node like any other package, system-wide. The script runs as root, so read it before running it if that matters to you. For Node 26:

curl -fsSL https://deb.nodesource.com/setup_26.x -o nodesource_setup.sh
sudo -E bash nodesource_setup.sh
sudo apt install -y nodejs
Copied

setup_lts.x in place of setup_26.x also points at 26 today. With a root-owned Node, a global npm install needs either sudo or npm’s prefix moved into your home, the trade-off the npm -g guide covers. A sensible split on a server is NodeSource for anything run by cron or systemd and nvm for interactive work; keep them apart by checking which node in each context, since whichever is first on the PATH wins.

fnm and Volta

fnm is a Node version manager written in Rust: one binary, the same .nvmrc files (and .node-version), and switching on directory change built in with --use-on-cd. It installs with curl -fsSL https://fnm.vercel.app/install | bash and loads into bash with eval "$(fnm env --use-on-cd --shell bash)", which means it has the same interactive-shell limits as nvm for cron and services. Volta, the other name in older tutorials, now says on its own README “Volta is unmaintained” and recommends mise; it is not a choice for a new server.

With Node in place, the agents’ own install pages pick up from here: installing Codex CLI covers its npm route and the alternatives that need no Node at all.

Give your AI agents a permanent cloud computer.

We set it up and secure it, so all you do is use them. Run Claude Code, Codex or any agent you use, more at once than your laptop can hold, and keep them working when it’s closed. Or have OpenClaw set up and run for you.

See the developer pod

From $24/mo · your own plan or API key

Get your OpenClaw agent

$29/mo, cancel anytime · model usage included