[Bug] Update process incorrectly switches to npm-local mode with legacy npm cache
Bug Description
Title: Update process incorrectly switches to npm-local mode when old npm cache entries exist
Description
After every Claude Code update, the installation switches from native to npm-local mode, causing a config mismatch. This requires manual intervention after each update to restore
proper operation.
Environment
- OS: Linux (Ubuntu)
- Claude Code version: 2.1.23
- Installation method: native
Steps to Reproduce
- Have a native Claude Code installation
- Previously have had an npm-based Claude Code installation (historical)
- Update Claude Code to a new version
- Run claude doctor
Expected Behavior
claude doctor shows consistent native installation with no warnings.
Actual Behavior
claude doctor shows config mismatch - running as npm-local while config specifies native. The CLI may fail to work properly until manually fixed.
Root Cause Analysis
Found 23 old @anthropic-ai/claude-code packages in the npm cache from a previous npm-based installation:
~/.npm/_cacache/content-v2/sha512/...
The update process appears to detect these cached packages and incorrectly switches to npm-local mode, overriding the native installation config.
Workaround
npm cache clean --force
rm -rf ~/.claude/local
claude install
This resolves the issue until the next update.
Suggested Fix(generated by claude code)
The updater should respect the configured installation method rather than auto-detecting based on npm cache presence. Options:
- Check config.json install method before deciding update strategy
- Clean up npm cache artifacts when user has native installation
- Add detection/warning in claude doctor when this mismatch condition exists
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗