Faqs
Claude update 和 npm install 怎么选
解释 Claude Code 更新时 claude update、npm install -g、npm update、Homebrew、WinGet、apt、dnf、apk 应该怎么选。
短答案:用最初安装 Claude Code 的同一个渠道更新。
最后核查:2026 年 7 月 7 日。npm
latestdist-tag 为2.1.202,stabledist-tag 为2.1.195。更新生产环境前,仍然要核对官方 changelog 和本机安装方式。
快速答案
当前 claude 来源 | 推荐更新方式 |
|---|---|
| Claude Code 原生安装器 | claude update |
| npm 全局包 | npm install -g @anthropic-ai/claude-code@latest |
| Homebrew | brew upgrade claude-code |
| WinGet | winget upgrade Anthropic.ClaudeCode |
| apt | sudo apt update && sudo apt install claude-code |
| dnf | sudo dnf upgrade claude-code |
| apk | sudo apk update && sudo apk add -u claude-code |
为什么 npm update -g 可能不是最新版
npm update -g @anthropic-ai/claude-code 会在 npm 已知的版本范围内更新。如果旧安装被版本范围限制,它不一定会跳到最新的 latest tag。
如果你明确要 npm 最新版,用:
npm install -g @anthropic-ai/claude-code@latest然后验证:
claude --version
npm view @anthropic-ai/claude-code dist-tags --json先判断安装方式
更新前先跑:
which claude
claude --version
npm list -g @anthropic-ai/claude-code --depth=0如果 which claude 指向 npm 全局目录,并且 npm list -g 能看到这个包,就用 npm 更新。否则优先按原生安装器或系统包管理器更新。
安全更新清单
- 用
claude --version看当前版本。 - 阅读 Claude Code changelog。
- 使用同一个安装渠道更新。
- 重启 shell、IDE、终端 agent 或 CI runner。
- 再跑
claude --version和一个小测试提示词。