- "command not found" is always a PATH issue — the binary exists but the shell doesn't know where to look
- Find the correct directory with
npm bin -g, then add it to PATH - Add the PATH export to your shell profile (~/.bashrc or ~/.zshrc) to make it permanent
- On macOS with zsh (the default since Catalina), edit ~/.zshrc not ~/.bashrc
- After editing the profile, run
source ~/.bashrc— opening a new terminal is not enough in all environments
OpenClaw installed successfully. npm install -g openclaw finished without errors. Then you type openclaw and get: "command not found." The package is on disk. The shell just doesn't know where to find it. This is a two-minute fix once you understand what's happening.
Why "Command Not Found" Happens
When you run a command, your shell searches through a list of directories called PATH — in order — looking for a binary with that name. If the binary isn't in any of those directories, the shell reports "command not found."
npm global packages install into a specific bin directory. That directory is often not in the default PATH — especially on fresh Linux servers, minimal Docker images, or macOS installations with custom npm configurations.
The problem isn't the installation. The problem is that the install directory isn't in the search path.
Confirm openclaw is actually installed:
npm list -g --depth=0 | grep openclaw
If it appears in the output, the package is installed. Now find where npm puts its global binaries:
npm bin -g
This prints something like /home/user/.npm-global/bin or /usr/local/bin. That directory needs to be in your PATH.
The 3-Line Fix
# Get the npm global bin path
NPM_BIN=$(npm bin -g)
# Add it to PATH for this session
export PATH="$NPM_BIN:$PATH"
# Verify it works
openclaw --version
This fixes the problem for the current terminal session. The next section makes it permanent.
$(npm bin -g)/openclaw --version. If this works, you've confirmed the binary is there and the fix is purely a PATH issue. If even the absolute path fails, the installation itself failed and you need to reinstall.Making the Fix Permanent
A PATH export in your current session disappears when you close the terminal. To make it permanent, add it to your shell profile file.
First, identify your shell:
echo $SHELL
Then edit the appropriate profile file:
For bash (/bin/bash):
echo 'export PATH="$(npm bin -g):$PATH"' >> ~/.bashrc
source ~/.bashrc
For zsh (/bin/zsh):
echo 'export PATH="$(npm bin -g):$PATH"' >> ~/.zshrc
source ~/.zshrc
After sourcing, openclaw --version works in the current session. Every new terminal session and reboot will also have the correct PATH automatically.
source ~/.bashrc (or source ~/.zshrc). Opening a new terminal window does source the profile automatically. But if you're in a script or systemd service, you need to source explicitly.macOS-Specific Issues
Since macOS Catalina (2019), the default shell changed from bash to zsh. If you've been adding PATH exports to ~/.bashrc and wondering why they don't stick, this is why — zsh reads ~/.zshrc.
On macOS with Apple Silicon (M1/M2/M3), Homebrew installs to /opt/homebrew. If you installed Node via Homebrew, npm's global bin might be at /opt/homebrew/bin, which is usually already in PATH if Homebrew is configured correctly. But npm's separate global directory for packages installed with npm install -g might still be elsewhere.
Check both:
# Where Homebrew's node puts global bins
which node
# Where npm puts global packages
npm bin -g
Both directories should be in your PATH. If either is missing, add the export to ~/.zshrc.
WSL and Windows Issues
On Windows Subsystem for Linux (WSL), openclaw should be installed and run inside the Linux environment, not the Windows host. If you installed Node.js on the Windows side and are trying to use it from WSL, the PATH won't cross the boundary correctly.
Install Node.js inside WSL using nvm — don't use the Windows Node.js installation from within the Linux shell:
# Inside WSL terminal
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
source ~/.bashrc
nvm install 20
npm install -g openclaw
openclaw --version
This keeps everything within the Linux environment and avoids the cross-environment PATH confusion that causes "command not found" in WSL setups.
Common Mistakes
Adding the PATH to the wrong profile file. bash uses ~/.bashrc for interactive sessions and ~/.bash_profile for login sessions. On macOS, login shells read ~/.bash_profile but not ~/.bashrc. Add the PATH export to both to be safe on macOS bash setups.
Not sourcing after editing. The current terminal session doesn't automatically re-read the profile file after you edit it. Always run source ~/.bashrc immediately after editing.
Using a hardcoded path in the profile. Writing export PATH="/home/user/.npm-global/bin:$PATH" breaks on a different user or when npm's prefix changes. Use $(npm bin -g) to resolve the path dynamically.
Running openclaw from a systemd service without PATH configured. systemd services start with a minimal environment — they don't inherit your user's PATH. Explicitly set the PATH in the service unit file with Environment="PATH=/home/user/.npm-global/bin:/usr/local/bin:/usr/bin:/bin".
Frequently Asked Questions
Why does it say 'openclaw: command not found' after installation?
The openclaw binary was installed but the directory containing it isn't in your shell's PATH. Run npm bin -g to find the directory, add it to PATH with export PATH="$(npm bin -g):$PATH", and add that line to your shell profile for a permanent fix.
How do I find where openclaw is installed?
Run npm list -g --depth=0 to confirm it's installed globally. Then run npm bin -g to see the exact binary directory. You can also run $(npm bin -g)/openclaw --version to test it directly with the full path.
How do I permanently fix the PATH for openclaw?
Add export PATH="$(npm bin -g):$PATH" to your shell profile (~/.bashrc for bash, ~/.zshrc for zsh). Then run source ~/.bashrc to apply it immediately. Every new terminal session will have the correct PATH automatically.
Why does openclaw work in one terminal but not another?
The PATH fix was added to the wrong profile file, or the profile wasn't sourced after editing. Check which shell you're using with echo $SHELL, confirm the export is in the matching profile file, and source it.
Does the command not found error happen on macOS differently than Linux?
On macOS, the default shell is zsh, so PATH changes go into ~/.zshrc rather than ~/.bashrc. On Apple Silicon, Homebrew installs to /opt/homebrew — confirm that's in PATH alongside the npm global bin directory.
Can I run openclaw without fixing PATH by using the full path?
Yes — use $(npm bin -g)/openclaw --version temporarily. But fixing PATH properly takes under two minutes and makes the command available everywhere, including in scripts and systemd services, without specifying the full path each time.
J. Donovan documents OpenClaw installation and configuration across Linux, macOS, Windows WSL, and containerized environments. Has written setup guides used by over 15,000 developers and specializes in making environment configuration errors immediately understandable and fixable.