[Bug] npm Install Fails: ENOTEMPTY Error During Global Package Update

Status Fixed / completed
Maintainer reply ✓ Yes — ant-kurt
Activity 8 comments · opened Aug 30, 2025 · closed Sep 2, 2025
💡 Likely answer: A maintainer (ant-kurt, collaborator) responded on this thread — see the highlighted reply below.

Bug Description
update problem with claude code
npm i -g @anthropic-ai/claude-code
npm error code ENOTEMPTY
npm error syscall rename
npm error path /opt/homebrew/lib/node_modules/@anthropic-ai/claude-code
npm error dest /opt/homebrew/lib/node_modules/@anthropic-ai/.claude-code-2DTsDk1V
npm error errno -66
npm error ENOTEMPTY: directory not empty, rename '/opt/homebrew/lib/node_modules/@anthropic-ai/claude-code' -> '/opt/homebrew/lib/node_modules/@anthropic-ai/.claude-code-2DTsDk1V'

Environment Info

  • Platform: darwin
  • Terminal: iTerm.app
  • Version: 1.0.96
  • Feedback ID: 94afdf2e-5918-4f92-b2ec-159a64883765

Errors

[{"error":"Error: Failed to install new version of claude:  npm error code ENOTEMPTY\nnpm error syscall rename\nnpm error path /opt/homebrew/lib/node_modules/@anthropic-ai/claude-code\nnpm error dest /opt/homebrew/lib/node_modules/@anthropic-ai/.claude-code-2DTsDk1V\nnpm error errno -66\nnpm error ENOTEMPTY: directory not empty, rename '/opt/homebrew/lib/node_modules/@anthropic-ai/claude-code' -> '/opt/homebrew/lib/node_modules/@anthropic-ai/.claude-code-2DTsDk1V'\nnpm error A complete log of this run can be found in: /Users/robert.schwegler/.npm/_logs/2025-08-30T08_04_35_594Z-debug-0.log\n    at l31 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1635:392)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:3555:10962","timestamp":"2025-08-30T08:04:35.926Z"},{"error":"Error: Failed to install new version of claude:  npm error code ENOTEMPTY\nnpm error syscall rename\nnpm error path /opt/homebrew/lib/node_modules/@anthropic-ai/claude-code\nnpm error dest /opt/homebrew/lib/node_modules/@anthropic-ai/.claude-code-2DTsDk1V\nnpm error errno -66\nnpm error ENOTEMPTY: directory not empty, rename '/opt/homebrew/lib/node_modules/@anthropic-ai/claude-code' -> '/opt/homebrew/lib/node_modules/@anthropic-ai/.claude-code-2DTsDk1V'\nnpm error A complete log of this run can be found in: /Users/robert.schwegler/.npm/_logs/2025-08-30T08_04_39_796Z-debug-0.log\n    at l31 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1635:392)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:3555:10962","timestamp":"2025-08-30T08:04:40.142Z"},{"error":"Error: Failed to install new version of claude:  npm error code ENOTEMPTY\nnpm error syscall rename\nnpm error path /opt/homebrew/lib/node_modules/@anthropic-ai/claude-code\nnpm error dest /opt/homebrew/lib/node_modules/@anthropic-ai/.claude-code-2DTsDk1V\nnpm error errno -66\nnpm error ENOTEMPTY: directory not empty, rename '/opt/homebrew/lib/node_modules/@anthropic-ai/claude-code' -> '/opt/homebrew/lib/node_modules/@anthropic-ai/.claude-code-2DTsDk1V'\nnpm error A complete log of this run can be found in: /Users/robert.schwegler/.npm/_logs/2025-08-30T08_05_08_241Z-debug-0.log\n    at l31 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1635:392)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:3555:10962","timestamp":"2025-08-30T08:05:08.641Z"},{"error":"Error: Failed to install new version of claude:  npm error code ENOTEMPTY\nnpm error syscall rename\nnpm error path /opt/homebrew/lib/node_modules/@anthropic-ai/claude-code\nnpm error dest /opt/homebrew/lib/node_modules/@anthropic-ai/.claude-code-2DTsDk1V\nnpm error errno -66\nnpm error ENOTEMPTY: directory not empty, rename '/opt/homebrew/lib/node_modules/@anthropic-ai/claude-code' -> '/opt/homebrew/lib/node_modules/@anthropic-ai/.claude-code-2DTsDk1V'\nnpm error A complete log of this run can be found in: /Users/robert.schwegler/.npm/_logs/2025-08-30T08_05_11_570Z-debug-0.log\n    at l31 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1635:392)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:3555:10962","timestamp":"2025-08-30T08:05:11.886Z"}]

View original on GitHub ↗

8 Comments

thejeed · 1 year ago

I’ve got the exact same error on Mac OS, didn‘t try the update manually, just noticed the „auto update failed“ in Claude Code and that claude was not found after exiting. So I tried npm i -g @anthropic-ai/claude-code which failed with the same message as mentioned by the op.

thephez · 12 months ago

I have the equivalent issue on Ubuntu. Temporarily running via npx until I get it fixed (npx -y @anthropic-ai/claude-code@latest).

ant-kurt collaborator · 12 months ago

Your npm installation is in a bad state, you'll need to manually delete the package. This will be something like:

rm -rf /opt/homebrew/lib/node_modules/@anthropic-ai/claude-code

and then you can re-install the latest version.

This will be a non-issue in the native build https://docs.anthropic.com/en/docs/claude-code/setup#native-binary-installation-beta

lowecg · 12 months ago

@ant-kurt I experience this consistently with npm i -g @anthropic-ai/claude-code

Using this command because Claude Code gave this message:

    ✗ Auto-update failed · Try claude doctor or npm i -g @anthropic-ai/claude-code
% npm i -g @anthropic-ai/claude-code
npm error code ENOTEMPTY
npm error syscall rename
npm error path /opt/homebrew/lib/node_modules/@anthropic-ai/claude-code
npm error dest /opt/homebrew/lib/node_modules/@anthropic-ai/.claude-code-2DTsDk1V
npm error errno -66
npm error ENOTEMPTY: directory not empty, rename '/opt/homebrew/lib/node_modules/@anthropic-ai/claude-code' -> '/opt/homebrew/lib/node_modules/@anthropic-ai/.claude-code-2DTsDk1V'
npm error A complete log of this run can be found in: /Users/lowecg/.npm/_logs/2025-09-04T06_44_26_089Z-debug-0.log
(base) lowecg@mbp /tmp

Remove and reinstall - but cannot update:

% rm -rf /opt/homebrew/lib/node_modules/@anthropic-ai/claude-code
(base) lowecg@mbp /tmp
% npm i -g @anthropic-ai/claude-code


added 12 packages in 442ms

11 packages are looking for funding
  run `npm fund` for details
(base) lowecg@mbp /tmp
% npm i -g @anthropic-ai/claude-code
npm error code ENOTEMPTY
npm error syscall rename
npm error path /opt/homebrew/lib/node_modules/@anthropic-ai/claude-code
npm error dest /opt/homebrew/lib/node_modules/@anthropic-ai/.claude-code-2DTsDk1V
npm error errno -66
npm error ENOTEMPTY: directory not empty, rename '/opt/homebrew/lib/node_modules/@anthropic-ai/claude-code' -> '/opt/homebrew/lib/node_modules/@anthropic-ai/.claude-code-2DTsDk1V'
npm error A complete log of this run can be found in: /Users/lowecg/.npm/_logs/2025-09-04T06_44_52_187Z-debug-0.log
(base) lowecg@mbp /tmp
% npm upgrade -g @anthropic-ai/claude-code
npm error code ENOTEMPTY
npm error syscall rename
npm error path /opt/homebrew/lib/node_modules/@anthropic-ai/claude-code
npm error dest /opt/homebrew/lib/node_modules/@anthropic-ai/.claude-code-2DTsDk1V
npm error errno -66
npm error ENOTEMPTY: directory not empty, rename '/opt/homebrew/lib/node_modules/@anthropic-ai/claude-code' -> '/opt/homebrew/lib/node_modules/@anthropic-ai/.claude-code-2DTsDk1V'
npm error A complete log of this run can be found in: /Users/lowecg/.npm/_logs/2025-09-04T06_45_00_057Z-debug-0.log

Here's the log from the last run:

2025-09-04T06_45_00_057Z-debug-0.log

Surely this is not right?

ant-kurt collaborator · 12 months ago

We recommend switching to a locally installed npm package via claude /migrate-installer or switching to the native executable (https://docs.anthropic.com/en/docs/claude-code/setup#native-binary-installation-beta).

tkfoss · 11 months ago

claude 1.0.110 broke my npm installation, now I have to remove it by hand. this was reported before, and also dismissed, but obv still unresolved. https://github.com/anthropics/claude-code/issues/471#issuecomment-2726301474

nevertoday · 11 months ago

same . how to solve

github-actions[bot] · 11 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.