跳轉到主要內容

系統需求

  • 作業系統:macOS 13.0+、Ubuntu 20.04+/Debian 10+ 或 Windows 10+(搭配 WSL 1、WSL 2 或 Git for Windows)
  • 硬體:4 GB+ RAM
  • 網路:需要網際網路連線(請參閱網路設定
  • Shell:在 Bash 或 Zsh 中效果最佳
  • 位置Anthropic 支援的國家

其他依賴項

安裝

To install Claude Code, use one of the following methods: 安裝程序完成後,導覽至您的專案並啟動 Claude Code:
cd your-awesome-project
claude
如果您在安裝期間遇到任何問題,請參閱疑難排解指南
安裝後執行 claude doctor 以檢查您的安裝類型和版本。
Alpine Linux 和其他 musl/uClibc 型發行版:原生安裝程式需要 libgcclibstdc++ripgrep。對於 Alpine:apk add libgcc libstdc++ ripgrep。設定 USE_BUILTIN_RIPGREP=0

驗證

針對個人

  1. Claude Pro 或 Max 方案(建議):訂閱 Claude 的 Pro 或 Max 方案,以取得包含 Claude Code 和網頁版 Claude 的統一訂閱。在一個地方管理您的帳戶,並使用您的 Claude.ai 帳戶登入。
  2. Claude Console:透過 Claude Console 連線並完成 OAuth 程序。需要在 Anthropic Console 中有效的帳單。系統會自動為使用情況追蹤和成本管理建立「Claude Code」工作區。您無法為 Claude Code 工作區建立 API 金鑰;它專門用於 Claude Code 使用。

針對團隊和組織

  1. Claude for Teams 或 Enterprise(建議):訂閱 Claude for TeamsClaude for Enterprise,以進行集中帳單、團隊管理,以及存取 Claude Code 和網頁版 Claude。團隊成員使用其 Claude.ai 帳戶登入。
  2. Claude Console 搭配團隊帳單:設定共用的 Claude Console 組織搭配團隊帳單。邀請團隊成員並指派角色以進行使用情況追蹤。
  3. 雲端提供者:設定 Claude Code 以使用 Amazon Bedrock、Google Vertex AI 或 Microsoft Foundry,以便與您現有的雲端基礎結構進行部署。

安裝特定版本

原生安裝程式接受特定版本號或發行通道(lateststable)。您在安裝時選擇的通道將成為自動更新的預設值。如需詳細資訊,請參閱設定發行通道 若要安裝最新版本(預設):
curl -fsSL https://claude.ai/install.sh | bash
若要安裝穩定版本:
curl -fsSL https://claude.ai/install.sh | bash -s stable
若要安裝特定版本號:
curl -fsSL https://claude.ai/install.sh | bash -s 1.0.58

二進位完整性和程式碼簽署

  • 所有平台的 SHA256 校驗和都發佈在發行資訊清單中,目前位於 https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/{VERSION}/manifest.json(範例:將 {VERSION} 替換為 2.0.30
  • 簽署的二進位檔案分佈在以下平台上:
    • macOS:由「Anthropic PBC」簽署並由 Apple 公證
    • Windows:由「Anthropic, PBC」簽署

NPM 安裝(已棄用)

NPM 安裝已棄用。盡可能使用原生安裝方法。若要將現有的 npm 安裝遷移至原生,請執行 claude install 全域 npm 安裝
npm install -g @anthropic-ai/claude-code
請勿使用 sudo npm install -g,因為這可能導致權限問題和安全風險。 如果您遇到權限錯誤,請參閱疑難排解權限錯誤以取得建議的解決方案。

Windows 設定

選項 1:WSL 中的 Claude Code
  • 支援 WSL 1 和 WSL 2
選項 2:使用 Git Bash 在原生 Windows 上執行 Claude Code
  • 需要 Git for Windows
  • 對於可攜式 Git 安裝,請指定您的 bash.exe 路徑:
    $env:CLAUDE_CODE_GIT_BASH_PATH="C:\Program Files\Git\bin\bash.exe"
    

更新 Claude Code

自動更新

Claude Code 會自動保持最新狀態,以確保您擁有最新的功能和安全修正。
  • 更新檢查:在啟動時和執行時定期執行
  • 更新程序:在背景自動下載並安裝
  • 通知:安裝更新時您會看到通知
  • 套用更新:更新在您下次啟動 Claude Code 時生效
Homebrew 和 WinGet 安裝不會自動更新。使用 brew upgrade claude-codewinget upgrade Anthropic.ClaudeCode 手動更新。已知問題:Claude Code 可能會在新版本在這些套件管理器中可用之前通知您有更新。如果升級失敗,請稍候並稍後重試。

設定發行通道

使用 autoUpdatesChannel 設定來設定 Claude Code 針對自動更新和 claude update 遵循的發行通道:
  • "latest"(預設):在新功能發佈時立即接收
  • "stable":使用通常約一週舊的版本,跳過有重大迴歸的發行版本
透過 /config自動更新通道進行設定,或將其新增至您的 settings.json 檔案
{
  "autoUpdatesChannel": "stable"
}
對於企業部署,您可以使用受管設定在整個組織中強制執行一致的發行通道。

停用自動更新

在您的 shell 或 settings.json 檔案中設定 DISABLE_AUTOUPDATER 環境變數:
export DISABLE_AUTOUPDATER=1

手動更新

claude update

解除安裝 Claude Code

如果您需要解除安裝 Claude Code,請遵循您的安裝方法的說明。

原生安裝

移除 Claude Code 二進位檔案和版本檔案: macOS、Linux、WSL:
rm -f ~/.local/bin/claude
rm -rf ~/.local/share/claude
Windows PowerShell:
Remove-Item -Path "$env:USERPROFILE\.local\bin\claude.exe" -Force
Remove-Item -Path "$env:USERPROFILE\.local\share\claude" -Recurse -Force
Windows CMD:
del "%USERPROFILE%\.local\bin\claude.exe"
rmdir /s /q "%USERPROFILE%\.local\share\claude"

Homebrew 安裝

brew uninstall --cask claude-code

WinGet 安裝

winget uninstall Anthropic.ClaudeCode

NPM 安裝

npm uninstall -g @anthropic-ai/claude-code

清理設定檔案(選用)

移除設定檔案將刪除您的所有設定、允許的工具、MCP 伺服器設定和工作階段歷史記錄。
若要移除 Claude Code 設定和快取資料: macOS、Linux、WSL:
# 移除使用者設定和狀態
rm -rf ~/.claude
rm ~/.claude.json

# 移除專案特定設定(從您的專案目錄執行)
rm -rf .claude
rm -f .mcp.json
Windows PowerShell:
# 移除使用者設定和狀態
Remove-Item -Path "$env:USERPROFILE\.claude" -Recurse -Force
Remove-Item -Path "$env:USERPROFILE\.claude.json" -Force

# 移除專案特定設定(從您的專案目錄執行)
Remove-Item -Path ".claude" -Recurse -Force
Remove-Item -Path ".mcp.json" -Force
Windows CMD:
REM 移除使用者設定和狀態
rmdir /s /q "%USERPROFILE%\.claude"
del "%USERPROFILE%\.claude.json"

REM 移除專案特定設定(從您的專案目錄執行)
rmdir /s /q ".claude"
del ".mcp.json"