Uninstall the Claude Code Node.js version and install the latest version

Let me first check the latest information about Claude Code installation.好的,以下是在 macOS 上從 npm 版本完整卸載並重新安裝最新 Claude Code 的步驟:

步驟一:卸載舊的 npm 版本

在終端機中依序執行:

# 卸載 npm 全域安裝的 Claude Code
npm uninstall -g @anthropic-ai/claude-code

步驟二:清除殘留設定檔(可選但建議)

# 移除設定與快取檔案
rm -rf ~/.claude
rm -rf ~/.claude-code
rm -rf ~/.config/claude-code
rm -rf ~/.cache/claude-code
rm -rf ~/Library/Application\ Support/claude-code
rm -rf ~/Library/Caches/claude-code

# 清除安裝鎖定狀態(避免安裝卡住)
rm -rf ~/.local/state/claude/locks/

步驟三:確認已完全移除

which claude
# 應該回傳空白或 "not found"

type -a claude
# 應該也是找不到

如果 which claude 仍顯示路徑,手動刪除該路徑下的檔案。

步驟四:安裝最新版(原生二進位,官方推薦)

Anthropic 現在推薦使用原生安裝器(native installer),不再需要 Node.js:

curl -fsSL https://claude.ai/install.sh | bash

安裝完成後驗證:

claude --version

步驟五:登入

執行 claude,會自動開啟瀏覽器引導你登入。你需要有 Pro、Max、Teams、Enterprise 或 Console 帳號。


重點提醒:

  • 原生安裝版會在背景自動更新,不需要手動維護版本
  • 如果你之前同時用過 npm + native 等多種方式安裝,建議全部清掉再重裝,混合安裝是大多數 Claude Code 問題的根源
  • 不要用 sudo npm install -g,這會導致權限問題