Claude 更新时遇到 npm error ENOTEMPTY: directory not empty, rename

更新 claude 版本时,总是遇到这个问题:

bash 复制代码
npm error ENOTEMPTY: directory not empty, rename '/Users/knight174/.nvm/versions/node/v22.20.0/lib/node_modules/@anthropic-ai/claude-code' -> '/Users/knight174/.nvm/versions/node/v22.20.0/lib/node_modules/@anthropic-ai/.claude-code-O54bD8cr'

记录一下解决方案:

第一步、移除已经存在的 claude-code 目录

bash 复制代码
rm -rf $(npm config get prefix)/lib/node_modules/@anthropic-ai/claude-code

第二步、移除之前 rename 生成的临时目录

bash 复制代码
rm -rf $(npm config get prefix)/lib/node_modules/@anthropic-ai/.claude-code-*

第三步、清除 npm 缓存

bash 复制代码
npm cache clean --force

第四步、重新安装 claude-code

bash 复制代码
npm i -g @anthropic-ai/claude-code
相关推荐
ServBay4 小时前
7 个AI开发中真正用得上的 MCP Server,配合Claude Code食用效果更佳
后端·claude·mcp
小七-七牛开发者7 小时前
Coding Agent 规则管理:CLAUDE.md、Skills、Hooks、Subagents 到底怎么选?
ai·大模型·agent·claude·token·loop·mcp·claudecode·ai coding
Flynt11 小时前
配置Chrome DevTools MCP,我在Windows上折腾了两个晚上
ai编程·claude·mcp
想要成为糕糕手11 小时前
Harness Engineering:大模型时代的“马鞍”——从记忆层开始,让AI真正为你所用
面试·ai编程·claude
Lsx_1 天前
不只是 Prompt:用 Superpowers Skill 给 AI 编程装上工程化工作流
前端·ai编程·claude
i晟1 天前
Claude对话机制深度解析:为什么 Claude Code 和你越聊越懂你?每句对话都要读一整个上下文吗?
agent·claude
Flynt1 天前
接手28万行遗留代码:我用codebase-memory-mcp把代码理解时间从3天压到2小时
ai编程·claude·mcp
uccs2 天前
流式响应的三次进化:EventSource → ReadableStream → TransformStream
openai·ai编程·claude