docs: fix npm prefix guidance
This commit is contained in:
@@ -155,18 +155,21 @@ Quick diagnosis:
|
|||||||
```bash
|
```bash
|
||||||
node -v
|
node -v
|
||||||
npm -v
|
npm -v
|
||||||
npm bin -g
|
npm prefix -g
|
||||||
echo "$PATH"
|
echo "$PATH"
|
||||||
```
|
```
|
||||||
|
|
||||||
If the output of `npm bin -g` is **not** present inside `echo "$PATH"`, your shell can’t 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 can’t find global npm binaries (including `clawdbot`).
|
||||||
|
|
||||||
Fix: add it to your shell startup file (zsh: `~/.zshrc`, bash: `~/.bashrc`):
|
Fix: add it to your shell startup file (zsh: `~/.zshrc`, bash: `~/.bashrc`):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
export PATH="/path/from/npm/bin/-g:$PATH"
|
# macOS / Linux
|
||||||
|
export PATH="$(npm prefix -g)/bin:$PATH"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
On Windows, add the output of `npm prefix -g` to your PATH.
|
||||||
|
|
||||||
Then open a new terminal (or `rehash` in zsh / `hash -r` in bash).
|
Then open a new terminal (or `rehash` in zsh / `hash -r` in bash).
|
||||||
|
|
||||||
## Update / uninstall
|
## Update / uninstall
|
||||||
|
|||||||
@@ -19,33 +19,36 @@ Run:
|
|||||||
```bash
|
```bash
|
||||||
node -v
|
node -v
|
||||||
npm -v
|
npm -v
|
||||||
npm bin -g
|
npm prefix -g
|
||||||
echo "$PATH"
|
echo "$PATH"
|
||||||
```
|
```
|
||||||
|
|
||||||
If the output of `npm bin -g` is **not** present inside `echo "$PATH"`, your shell can’t 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 can’t find global npm binaries (including `clawdbot`).
|
||||||
|
|
||||||
## Fix: put npm’s global bin dir on PATH
|
## Fix: put npm’s global bin dir on PATH
|
||||||
|
|
||||||
1) Find your global bin directory:
|
1) Find your global npm prefix:
|
||||||
|
|
||||||
```bash
|
```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`
|
- zsh: `~/.zshrc`
|
||||||
- bash: `~/.bashrc`
|
- bash: `~/.bashrc`
|
||||||
|
|
||||||
Example (replace the path with your `npm bin -g` output):
|
Example (replace the path with your `npm prefix -g` output):
|
||||||
|
|
||||||
```bash
|
```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).
|
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)
|
## Fix: avoid `sudo npm install -g` / permission errors (Linux)
|
||||||
|
|
||||||
If `npm install -g ...` fails with `EACCES`, switch npm’s global prefix to a user-writable directory:
|
If `npm install -g ...` fails with `EACCES`, switch npm’s global prefix to a user-writable directory:
|
||||||
@@ -63,7 +66,7 @@ Persist the `export PATH=...` line in your shell startup file.
|
|||||||
You’ll have the fewest surprises if Node/npm are installed in a way that:
|
You’ll have the fewest surprises if Node/npm are installed in a way that:
|
||||||
|
|
||||||
- keeps Node updated (22+)
|
- 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:
|
Common choices:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user