OmniscioGuidesnpm error code ENOTEMPTY
Claude Code: npm error code ENOTEMPTY when updating
Last checked against Anthropic's documentation on November 18, 2026. By the Omniscio team. Updated .
What is the exact message?
npm error code ENOTEMPTY
npm error syscall rename
npm error path /home/you/.nvm/versions/node/v22.13.1/lib/node_modules/@anthropic-ai/claude-code
npm error dest /home/you/.nvm/versions/node/v22.13.1/lib/node_modules/@anthropic-ai/.claude-code-tVWAnUUt
npm error errno -39
npm error ENOTEMPTY: directory not empty, rename '...'That is Anthropic's example from its installation troubleshooting page. The two paths on your screen will be different; only the shape stays the same. The npm error path line names the directory npm could not move.
What does it mean?
You ran an update over an existing install, and npm tried to rename the old package directory out of the way before putting the new version in place. The rename failed, so the command ended with the old files untouched.
The line npm error errno -39 carries the same story: the target directory was not empty, so npm would not move into it. Nothing in the message says Claude Code is broken, because it is not.
Why is the directory not empty?
- An earlier run stopped part way. Anthropic says interrupted runs can leave
.claude-code-*directories beside the package, and this update trips over them. - You switched Node versions. With nvm, each Node version has its own global package directory, and the one the error names may not be the one
npm root -gprints now.
How do I fix it?
- Read the
npm error pathline. That is the directory npm could not move. Everything else on this page follows from it. - Delete that directory. On macOS or Linux, Anthropic's command is
rm -rf "$(npm root -g)/@anthropic-ai/claude-code". If the error's path is not under whatnpm root -gprints, delete the path the error names instead. - Delete the leftovers beside it. Still on macOS or Linux:
rm -rf "$(npm root -g)/@anthropic-ai/.claude-code-"*. If Zsh answersno matches found, there was nothing to remove, which is the answer you want. - On Windows, use one PowerShell command for both. Anthropic gives
Remove-Item -Recurse -Force "$(npm root -g)/@anthropic-ai/claude-code", "$(npm root -g)/@anthropic-ai/.claude-code-*". - Reinstall. Run
npm install -g @anthropic-ai/claude-code@latest, then confirm with the version check below. - Ready to leave npm behind? Anthropic's troubleshooting page gives the native installer as the way out of npm's own install problems.
curl -fsSL https://claude.ai/install.sh | bashinstalls it, and the npm package can then be removed.
One exception to step 5: on npm 12 the reinstall can finish without placing the binary, because npm 12 skips the postinstall step by default. Check npm --version first and follow Anthropic's npm 12 install fix if it starts with 12.
How do I know it worked?
claude --versionprints a version number, such as2.1.211 (Claude Code). Anthropic gives that exact form as the confirmation.- The reinstall ends with npm's own success lines instead of
npm error code ENOTEMPTY. - If the version prints but
claudedoes not run, the command not found guide separates a PATH problem from an install that did not finish.
Where these answers come from
- The message, word for word, the two paths, the delete-and-reinstall steps and the Zsh note: Anthropic's installation troubleshooting, read November 18, 2026.
- The native installer command and the npm install method: Set up Claude Code, read November 18, 2026.
- The confirmation command and its output form: the same troubleshooting page's npm section, read November 18, 2026.
Common questions
Does this break my current install?
The command ended at the rename, so the new version was not put in place. The directory the error names is the one that needs removing before a reinstall can work.
Can I just run the update again?
Anthropic's fix is to delete first, then reinstall. Running the same command again leaves the directory in place, which is the condition that failed.
Why does the path mention nvm?
Because npm installs global packages inside the Node version that is active. If you changed Node versions since the last install, the old package sits in the old version's directory.
Will this happen again after the next update?
Not from the same leftovers, because they are gone. Anthropic also says interrupted runs can create them again, so an update you cancel part way can bring the message back.