openclaw - 💡(How to fix) Fix Bug: openclaw command not found after npm global install

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

After running npm install -g openclaw, the openclaw command is not found in the shell. Users get a "command not found" error and must manually configure their PATH.

Root Cause

When npm's global prefix is set to a user-level directory (e.g., ~/.npm-global), the global bin directory (~/.npm-global/bin) is not in the user's default PATH. This happens commonly when users follow npm's recommended setup to avoid sudo for global installs.

On a fresh macOS setup:

  • npm config get prefix/Users/<user>/.npm-global
  • Binary installs to ~/.npm-global/bin/openclaw
  • ~/.npm-global/bin is not in the default PATH

Fix Action

Fix / Workaround

Current Workaround

Code Example

mkdir ~/.npm-global
   npm config set prefix '~/.npm-global'

---

npm install -g openclaw

---

# ~/.zshrc
export PATH="$HOME/.npm-global/bin:$PATH"
RAW_BUFFERClick to expand / collapse

Problem Description

After running npm install -g openclaw, the openclaw command is not found in the shell. Users get a "command not found" error and must manually configure their PATH.

Root Cause

When npm's global prefix is set to a user-level directory (e.g., ~/.npm-global), the global bin directory (~/.npm-global/bin) is not in the user's default PATH. This happens commonly when users follow npm's recommended setup to avoid sudo for global installs.

On a fresh macOS setup:

  • npm config get prefix/Users/<user>/.npm-global
  • Binary installs to ~/.npm-global/bin/openclaw
  • ~/.npm-global/bin is not in the default PATH

Environment

  • OS: macOS (Darwin arm64)
  • Shell: zsh
  • npm global prefix: ~/.npm-global (user-level, no sudo)
  • OpenClaw version: latest (npm)
  • Node.js: v24.x

Steps to Reproduce

  1. Configure npm to use a user-level global prefix (one-time setup):
    mkdir ~/.npm-global
    npm config set prefix '~/.npm-global'
  2. Install OpenClaw globally:
    npm install -g openclaw
  3. Run openclaw
  4. Get zsh: command not found: openclaw

Current Workaround

Manually add the npm global bin directory to PATH in shell config:

# ~/.zshrc
export PATH="$HOME/.npm-global/bin:$PATH"

Then restart the shell or run source ~/.zshrc.

Expected Behavior

The install process should handle this gracefully. Ideally one of:

  1. postinstall script that detects if the npm global bin directory is in PATH and prints clear instructions if not
  2. Documentation with explicit post-install PATH setup steps for user-level npm prefixes
  3. Alternative install method (e.g., curl | sh wrapper that handles PATH setup)

Proposed Solutions

  1. Add a postinstall script in package.json that:

    • Detects the npm global bin path via process.env.npm_config_prefix
    • Checks if it's in the user's PATH
    • Prints a clear, actionable message with the exact export PATH=... command needed
  2. Update the Getting Started docs to include a "Verify PATH" step after npm install, with instructions for common shells (bash, zsh, fish)

  3. Enhance install.sh to detect and offer to configure PATH automatically (write to .zshrc/.bashrc with user confirmation)

Additional Context

This is a common pain point for npm global installs in general, but CLI tools with immediate user interaction (like OpenClaw) should handle it more gracefully than most. Users who are new to Node/npm will be especially confused by this.

Related issues:

  • #73814 - Installer hangs with truncated warn_shell_path_missing_di function (install.sh PATH detection)
  • #79048 - Impossible to install on mac (different root cause but similar user frustration)
  • #80387 - Command disappears after brew upgrade (related PATH/node_modules resolution)

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Bug: openclaw command not found after npm global install