[Bug] Auto-update fails with npm ENOTEMPTY rename error

Resolved 💬 13 comments Opened Sep 10, 2025 by wdelhagen Closed Feb 11, 2026

Bug Description
I keep getting auto-update errors. When I quit and attempt to do the update myself, it fails because of some kind of corruption of the global npm package install. I then have to manually delete the entire package and do a fresh install.

This is the message I get in the Claude Code terminal at the bottom in red text:

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

This is the error I get when I exit and attempt to update manually:

❯ npm i -g @anthropic-ai/claude-code
npm error code ENOTEMPTY
npm error syscall rename
npm error path /Users/<username_redacted>/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code
npm error dest /Users/<username_redacted>/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/.claude-code-0ePLndiR
npm error errno -66
npm error ENOTEMPTY: directory not empty, rename '/Users/<username_redacted>/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code' -> '/Users/<username_redacted>/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/.claude-code-0ePLndiR'
npm error A complete log of this run can be found in: /Users/willd/.npm/_logs/2025-09-10T00_42_19_467Z-debug-0.log

It only works again if it rm -rf the claude-code package directory and then run a fresh install.

Environment Info

  • Platform: darwin
  • Terminal: iTerm.app
  • Version: 1.0.109
  • Feedback ID: d27b86f3-3c19-4ec8-8f2f-25c081fd7abe

Errors

[{"error":"Error: Request was aborted.\n    at i61._createMessage (file:///Users/<username_redacted>/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code/cli.js:971:7955)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)","timestamp":"2025-09-10T00:03:30.151Z"},{"error":"SyntaxError: Unexpected token 'I', \"I apologiz\"... is not valid JSON\n    at JSON.parse (<anonymous>)\n    at file:///Users/<username_redacted>/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code/cli.js:733:9932\n    at Q (file:///Users/<username_redacted>/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code/cli.js:713:13288)\n    at at2 (file:///Users/<username_redacted>/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code/cli.js:1095:1982)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)","timestamp":"2025-09-10T00:19:44.828Z"},{"error":"Error: Failed to install new version of claude:  npm error code ENOTEMPTY\nnpm error syscall rename\nnpm error path /Users/<username_redacted>/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code\nnpm error dest /Users/<username_redacted>/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/.claude-code-0ePLndiR\nnpm error errno -66\nnpm error ENOTEMPTY: directory not empty, rename '/Users/<username_redacted>/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code' -> '/Users/<username_redacted>/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/.claude-code-0ePLndiR'\nnpm error A complete log of this run can be found in: /Users/<username_redacted>/.npm/_logs/2025-09-10T00_28_21_539Z-debug-0.log\n    at IG1 (file:///Users/<username_redacted>/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code/cli.js:1612:393)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async Object.current (file:///Users/<username_redacted>/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code/cli.js:3563:12159)","timestamp":"2025-09-10T00:28:22.061Z"}]

View original on GitHub ↗

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