[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

  1. Have old Claude Code installation at /usr/local/bin/claude (version 1.0.126)
  2. Run sudo npm install -g @anthropic-ai/claude-code@latest
  3. New version installs to /usr/bin/claude via symlink
  4. Run claude --version - shows 1.0.126 (old binary in PATH takes precedence)
  5. Authentication fails with 401 errors

Expected Behavior

  • npm install/update should detect and remove/warn about old binaries
  • Or installation should prioritize /usr/local/bin to override old versions
  • At minimum, warn users if multiple claude binaries exist

Actual Behavior

  • Old binary remains and shadows new installation
  • which claude returns /usr/local/bin/claude (old version)
  • Users get authentication errors because old version doesn't support new auth flow
  • claude --version misleadingly 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:

  1. Check for old binaries in common locations (/usr/local/bin, etc.)
  2. Warn or prompt user to remove old installations
  3. Or create symlink at /usr/local/bin/claude pointing to npm global version

View original on GitHub ↗

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