Skip to content

OpenClaw: Command Not Found? Fix Your PATH in 5 Minutes

The "openclaw: command not found" error almost always means npm's global bin directory is not on your shell's PATH. This guide gives the exact fix for macOS zsh, Linux bash, and Windows, plus the nvm gotcha that silently removes the command.

You just ran npm install -g openclaw@latest, npm reported success, and then the very next command failed: openclaw: command not found. Nothing is broken and nothing needs reinstalling. The binary is on your disk; your shell just does not know where to look for it. This is the single most common OpenClaw install issue, and the fix is a one-line PATH change.

openclaw: command not found

The exact wording depends on your shell. zsh on macOS says zsh: command not found: openclaw, bash on Linux says openclaw: command not found, and Windows PowerShell says 'openclaw' is not recognized as the name of a cmdlet, function, script file, or operable program. All three mean the same thing: the directory where npm placed the openclaw executable is not listed in your PATH environment variable, so the shell cannot find it.

Diagnose it in ten seconds:

npm prefix -g
echo "$PATH"

The first command prints npm's global prefix; the executables live in the bin folder under it (on Windows, directly in the prefix folder). If that location does not appear anywhere in your PATH output, you have found the problem.

Fix on macOS (zsh)

macOS has used zsh as the default shell since Catalina, so the file to edit is ~/.zshrc.

  1. Confirm where npm installs globals: npm prefix -g. With Homebrew Node this is usually /opt/homebrew, which is already on PATH; the error usually appears when the prefix is a custom directory like ~/.npm-global.
  2. Append the bin directory to your PATH: echo 'export PATH="$(npm prefix -g)/bin:$PATH"' >> ~/.zshrc
  3. Reload the shell config: source ~/.zshrc
  4. Verify: command -v openclaw should print the full path, and openclaw --version should print a version number.

Fix on Linux (bash)

  1. Run npm prefix -g. If Node came from your distro or NodeSource, the prefix is often /usr/local or /usr, which is already on PATH. If you followed npm's EACCES advice and set a user prefix like ~/.npm-global, that is the missing piece.
  2. Add it to your shell config: echo 'export PATH="$(npm prefix -g)/bin:$PATH"' >> ~/.bashrc
  3. Apply it: source ~/.bashrc
  4. Verify with which openclaw and openclaw --version.

On a headless VPS, remember that non-login shells and systemd services read PATH differently. If a service cannot find openclaw, reference the binary by its absolute path from step 1.

Fix on Windows

  1. Check whether Windows can see the command at all: where.exe openclaw
  2. Find npm's global folder: npm prefix -g. The default is %AppData%\npm (for example C:\Users\you\AppData\Roaming\npm).
  3. Add that folder to PATH: open Start, search "environment variables", open Environment Variables, select Path under your user variables, click Edit, then New, and paste the folder from step 2.
  4. Close and reopen your terminal. Windows only reads PATH at startup, so an old PowerShell window will keep failing even after the fix.
  5. Verify: where.exe openclaw and openclaw --version.

The npm Prefix Trap

If your prefix looks wrong (for example it points into an old Node install that no longer exists), reset it. Run npm config get prefix to see the configured value, and if it is stale, remove the override so npm falls back to its default:

npm config delete prefix

Then reinstall once with npm install -g openclaw@latest so the binary lands in the correct, on-PATH location.

The nvm Gotcha

nvm keeps a separate global package folder per Node version. That has two consequences that look exactly like a broken install:

  1. If you installed openclaw under Node 22 and later ran nvm use 24, the command disappears, because Node 24's global folder never had it. Reinstall under the new version, or migrate everything at once: nvm install 24 --reinstall-packages-from=22
  2. Scripts, cron jobs, and CI shells often do not load nvm at all, so PATH lacks the nvm shims entirely. Use the absolute path printed by command -v openclaw in those contexts.

Also note OpenClaw's requirement: Node 22.19+, 23.11+, or 24+. If nvm has you on an older version, the install itself may misbehave before PATH ever becomes the issue.

Still Stuck? Use the Official Installer

OpenClaw's installer script handles Node versioning and PATH setup for you, which sidesteps this entire class of problem:

curl -fsSL https://openclaw.ai/install.sh | bash

On Windows PowerShell:

iwr -useb https://openclaw.ai/install.ps1 | iex

After any fix, run the full verification trio: openclaw --version, openclaw doctor, and openclaw gateway status.

Frequently Asked Questions

Why does sudo openclaw also say command not found?

sudo runs with its own restricted PATH (secure_path on most Linux distros), which does not include user-level npm folders. Avoid running openclaw with sudo at all; it is designed to run as your normal user. If you truly need root, call the binary by its absolute path.

Do I need to reinstall OpenClaw after fixing my PATH?

No. The npm install already put the binary on disk; the PATH fix just lets your shell find it. Reinstalling is only needed in the nvm case, where the new Node version genuinely has no copy of the package.

Why does openclaw work in one terminal but not another?

Different shells read different config files: zsh reads ~/.zshrc, bash reads ~/.bashrc or ~/.bash_profile, and non-login shells may skip some of them. If you added the PATH export to only one file, only that shell benefits. Add the same export line to the config file of every shell you use.

And if you would rather skip PATH surgery on a server entirely, a managed OpenClaw host ships with the CLI installed, on PATH, and kept up to date.

Frequently asked questions

Why does sudo openclaw also say command not found?
sudo runs with its own restricted PATH (secure_path on most Linux distros), which does not include user-level npm folders. Avoid running openclaw with sudo at all; it is designed to run as your normal user. If you truly need root, call the binary by its absolute path.
Do I need to reinstall OpenClaw after fixing my PATH?
No. The npm install already put the binary on disk; the PATH fix just lets your shell find it. Reinstalling is only needed in the nvm case, where the new Node version genuinely has no copy of the package.
Why does openclaw work in one terminal but not another?
Different shells read different config files: zsh reads ~/.zshrc, bash reads ~/.bashrc or ~/.bash_profile, and non-login shells may skip some of them. If you added the PATH export to only one file, only that shell benefits. Add the same export line to the config file of every shell you use.
OpenClaw Command Not Found: Fix PATH on Mac, Linux, Windows