Auto-update failed after restart — npm prefix mismatch (user-local install vs. system prefix)

Resolved 💬 3 comments Opened Mar 7, 2026 by kuppit-at Closed Mar 8, 2026

Description

After every restart, the following error appears when starting Claude Code:

✗ Auto-update failed · Try claude doctor or npm i -g @anthropic-ai/claude-code

Running sudo npm update -g @anthropic-ai/claude-code executes without errors but does not fix the issue, because Claude Code is installed user-locally (~/.local/) while npm's global prefix points to /usr (system-wide).

Steps to Reproduce

  1. Install Claude Code via npm install -g without an explicit prefix (ends up in ~/.local/)
  2. Restart the system
  3. Start Claude Code → auto-update error appears on every launch

Environment

| | |
|---|---|
| Claude Code | 2.1.70 |
| Node.js | v25.7.0 |
| npm | 11.11.0 |
| OS | CachyOS Linux (Arch-based) |
| Kernel | 6.19.6-2-cachyos |
| Shell | bash / zsh |

Root Cause

claude binary:  /home/kuppit/.local/bin/claude
→ symlink to:   /home/kuppit/.local/lib/node_modules/@anthropic-ai/claude-code/cli.js

npm global prefix: /usr
→ npm i -g would install to: /usr/lib/node_modules/  (requires root)

Claude Code is installed user-locally under ~/.local/, but npm config get prefix returns /usr. The auto-updater calls npm i -g @anthropic-ai/claude-code which targets the wrong prefix — either failing due to missing permissions or updating a different (system-level) location that claude does not use.

Expected Behavior

The auto-updater should detect the actual installation path of Claude Code (e.g. by resolving the symlink of which claude or using require.resolve) and invoke npm with the correct prefix accordingly.

Workaround

npm install -g --prefix ~/.local @anthropic-ai/claude-code

This updates the user-local installation without requiring sudo.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗