docs: fix npm prefix guidance

This commit is contained in:
Peter Steinberger
2026-01-22 04:26:18 +00:00
parent 55ead9636c
commit 351c73be01
2 changed files with 17 additions and 11 deletions

View File

@@ -19,33 +19,36 @@ Run:
```bash
node -v
npm -v
npm bin -g
npm prefix -g
echo "$PATH"
```
If the output of `npm bin -g` is **not** present inside `echo "$PATH"`, your shell cant find global npm binaries (including `clawdbot`).
If `$(npm prefix -g)/bin` (macOS/Linux) or `$(npm prefix -g)` (Windows) is **not** present inside `echo "$PATH"`, your shell cant find global npm binaries (including `clawdbot`).
## Fix: put npms global bin dir on PATH
1) Find your global bin directory:
1) Find your global npm prefix:
```bash
npm bin -g
npm prefix -g
```
2) Add it to your shell startup file:
2) Add the global npm bin directory to your shell startup file:
- zsh: `~/.zshrc`
- bash: `~/.bashrc`
Example (replace the path with your `npm bin -g` output):
Example (replace the path with your `npm prefix -g` output):
```bash
export PATH="/path/from/npm/bin/-g:$PATH"
# macOS / Linux
export PATH="/path/from/npm/prefix/bin:$PATH"
```
Then open a **new terminal** (or run `rehash` in zsh / `hash -r` in bash).
On Windows, add the output of `npm prefix -g` to your PATH.
## Fix: avoid `sudo npm install -g` / permission errors (Linux)
If `npm install -g ...` fails with `EACCES`, switch npms global prefix to a user-writable directory:
@@ -63,7 +66,7 @@ Persist the `export PATH=...` line in your shell startup file.
Youll have the fewest surprises if Node/npm are installed in a way that:
- keeps Node updated (22+)
- makes `npm bin -g` stable and on PATH in new shells
- makes the global npm bin dir stable and on PATH in new shells
Common choices: