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.
- 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. - Append the bin directory to your PATH:
echo 'export PATH="$(npm prefix -g)/bin:$PATH"' >> ~/.zshrc - Reload the shell config:
source ~/.zshrc - Verify:
command -v openclawshould print the full path, andopenclaw --versionshould print a version number.
Fix on Linux (bash)
- Run
npm prefix -g. If Node came from your distro or NodeSource, the prefix is often/usr/localor/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. - Add it to your shell config:
echo 'export PATH="$(npm prefix -g)/bin:$PATH"' >> ~/.bashrc - Apply it:
source ~/.bashrc - Verify with
which openclawandopenclaw --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
- Check whether Windows can see the command at all:
where.exe openclaw - Find npm's global folder:
npm prefix -g. The default is%AppData%\npm(for exampleC:\Users\you\AppData\Roaming\npm). - Add that folder to PATH: open Start, search "environment variables", open Environment Variables, select
Pathunder your user variables, click Edit, then New, and paste the folder from step 2. - Close and reopen your terminal. Windows only reads PATH at startup, so an old PowerShell window will keep failing even after the fix.
- Verify:
where.exe openclawandopenclaw --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:
- 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 - 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 openclawin 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.
Related guides
- OpenClaw Stuck on Starting (or the Control Panel Will Not Open)When OpenClaw hangs on startup it is almost always a port conflict, a broken config file, the wrong Node version, or a service manager hiding an interactive prompt. When the gateway runs but the control panel will not open, an expired dashboard token or a blocked port is the usual cause. This guide covers every fix with exact commands.
- How to Fix "OpenClaw Gateway Connect Failed: Pairing Required"The pairing required error means the OpenClaw Gateway rejected your client because its device identity or token is not approved. Approving the pending device or refreshing the gateway token fixes it in under five minutes.
- Where Is the OpenClaw Config File?OpenClaw keeps its configuration in a single JSON5 file at ~/.openclaw/openclaw.json on every OS. This guide shows how to find the active file, edit it without breaking the gateway, regenerate it from scratch, and which fields not to touch.
- Fixing "API rate limit reached, please try again" in OpenClawThis error means your model provider returned a 429, not that OpenClaw is broken. Learn what the limit means on Anthropic, OpenAI, and Groq, how OpenClaw's cooldown and fallback logic behaves, and how to configure fallbacks so one throttled key never stops your agent.
