[BUG] npm update/install doesn't remove old binary - /usr/local/bin/claude shadows newer version
Resolved 💬 4 comments Opened Mar 11, 2026 by pvestal Closed Mar 15, 2026
Bug Description
When updating Claude Code via npm, old binaries at /usr/local/bin/claude are not removed and shadow the newer npm-installed version, causing authentication failures and version confusion.
Environment
- OS: Linux (Ubuntu)
- Old version: 1.0.126 at
/usr/local/bin/claude - New version: 2.1.72 at
/usr/bin/claude(npm global) - npm global root:
/usr/lib/node_modules
Reproduction Steps
- Have old Claude Code installation at
/usr/local/bin/claude(version 1.0.126) - Run
sudo npm install -g @anthropic-ai/claude-code@latest - New version installs to
/usr/bin/claudevia symlink - Run
claude --version- shows 1.0.126 (old binary in PATH takes precedence) - Authentication fails with 401 errors
Expected Behavior
npm install/updateshould detect and remove/warn about old binaries- Or installation should prioritize
/usr/local/binto override old versions - At minimum, warn users if multiple
claudebinaries exist
Actual Behavior
- Old binary remains and shadows new installation
which claudereturns/usr/local/bin/claude(old version)- Users get authentication errors because old version doesn't support new auth flow
claude --versionmisleadingly shows old version
Workaround
# Find all claude installations
which -a claude
# Remove old binary
sudo rm /usr/local/bin/claude
# Verify correct version
claude --version # Now shows 2.1.72
System Info
$ which -a claude
/usr/local/bin/claude # OLD (1.0.126)
/usr/bin/claude # NEW (symlink to npm global)
/bin/claude # NEW (symlink to npm global)
$ ls -la /usr/bin/claude
lrwxrwxrwx 1 root root 52 Mar 11 16:07 /usr/bin/claude -> ../lib/node_modules/@anthropic-ai/claude-code/cli.js
Suggested Fix
Add post-install script to:
- Check for old binaries in common locations (
/usr/local/bin, etc.) - Warn or prompt user to remove old installations
- Or create symlink at
/usr/local/bin/claudepointing to npm global version
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗