Auto-update fails with ENOTEMPTY error on repeated attempts
Resolved 💬 3 comments Opened Jan 9, 2026 by Ai-Eli-ML Closed Jan 13, 2026
Description
Claude Code auto-update consistently fails with npm ENOTEMPTY error when updating. The auto-updater tries to rename the existing directory but fails if a temp directory from a previous failed update exists.
Error
npm error code ENOTEMPTY
npm error syscall rename
npm error path ~/.nvm/versions/node/v20.19.5/lib/node_modules/@anthropic-ai/claude-code
npm error dest ~/.nvm/versions/node/v20.19.5/lib/node_modules/@anthropic-ai/.claude-code-XXXXX
npm error errno -39
npm error ENOTEMPTY: directory not empty, rename '...' -> '...'
Environment
- OS: Linux (WSL2)
- Node: v20.19.5 (via nvm)
- Claude Code: 2.1.2
Steps to Reproduce
- Have Claude Code installed via npm
- Auto-update triggers (or fails once)
- Subsequent auto-updates fail with ENOTEMPTY
Workaround
rm -rf ~/.nvm/versions/node/v20.19.5/lib/node_modules/@anthropic-ai
npm i -g @anthropic-ai/claude-code
Suggested Fix
The auto-updater should clean up any existing .claude-code-* temp directories before attempting the rename operation.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗