Skip to content

安装配置

系统要求

项目要求
操作系统macOS 13.0+、Windows 10 1809+、Ubuntu 20.04+、Debian 10+、Alpine Linux 3.19+
内存4 GB 以上 RAM
网络需要互联网连接
ShellBash、Zsh、PowerShell 或 CMD。Windows 上需要 Git for Windows
地区Anthropic 支持的国家

安装方法

原生安装(推荐)

macOS / Linux / WSL:

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

Windows PowerShell:

powershell
irm https://claude.ai/install.ps1 | iex

Windows CMD:

batch
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd

原生安装会在后台自动更新,始终保持最新版本。

Homebrew(macOS)

bash
brew install --cask claude-code

Homebrew 安装不会自动更新,需定期运行 brew upgrade claude-code

WinGet(Windows)

powershell
winget install Anthropic.ClaudeCode

WinGet 安装不会自动更新,需定期运行 winget upgrade Anthropic.ClaudeCode


验证安装

bash
# 检查版本
claude --version

# 全面诊断(检查配置、MCP、插件等)
claude doctor

Windows 特殊配置

原生 Windows(使用 Git Bash)

安装 Git for Windows,安装时选择"Add to PATH"。

如果 Claude Code 找不到 Git Bash,在 settings.json 中指定路径:

json
{
  "env": {
    "CLAUDE_CODE_GIT_BASH_PATH": "C:\\Program Files\\Git\\bin\\bash.exe"
  }
}

WSL 配置

WSL 1 和 WSL 2 均支持。WSL 2 支持沙盒隔离(更安全),WSL 1 不支持。

OAuth 登录问题:WSL 中浏览器可能无法自动打开,设置浏览器路径:

bash
export BROWSER="/mnt/c/Program Files/Google/Chrome/Application/chrome.exe"
claude

或者按 c 复制 OAuth URL 手动在 Windows 浏览器打开。


Alpine Linux 配置

Alpine 和其他基于 musl/uClibc 的发行版需要额外安装依赖:

bash
apk add libgcc libstdc++ ripgrep

然后在 settings.json 中设置:

json
{
  "env": {
    "USE_BUILTIN_RIPGREP": "0"
  }
}

更新管理

自动更新

原生安装会在启动时和运行过程中自动检查更新,后台下载后在下次启动时生效。

配置更新频道

频道说明
latest(默认)新功能发布后立即获取
stable约延迟一周,跳过有重大回退的版本

/config 中切换,或修改 settings.json

json
{
  "autoUpdatesChannel": "stable"
}

禁用自动更新

json
{
  "env": {
    "DISABLE_AUTOUPDATER": "1"
  }
}

手动更新

bash
claude update

安装指定版本

bash
# macOS/Linux/WSL - 安装 stable 频道
curl -fsSL https://claude.ai/install.sh | bash -s stable

# 安装特定版本号
curl -fsSL https://claude.ai/install.sh | bash -s 1.0.58

# Windows PowerShell - 安装 stable
& ([scriptblock]::Create((irm https://claude.ai/install.ps1))) stable

账户认证

Claude Code 需要以下账户类型之一:

  • Claude Pro / Max / Teams / Enterprise(推荐,按订阅计费)
  • Claude Console(API 用量计费)
  • Amazon Bedrock、Google Vertex AI、Microsoft Foundry(企业云服务商)

免费版 Claude.ai 不包含 Claude Code 访问权限。

安装后运行 claude,按提示完成浏览器登录即可。


卸载

原生安装

macOS/Linux/WSL:

bash
rm -f ~/.local/bin/claude
rm -rf ~/.local/share/claude

Windows PowerShell:

powershell
Remove-Item -Path "$env:USERPROFILE\.local\bin\claude.exe" -Force
Remove-Item -Path "$env:USERPROFILE\.local\share\claude" -Recurse -Force

Homebrew

bash
brew uninstall --cask claude-code

WinGet

powershell
winget uninstall Anthropic.ClaudeCode

清除配置文件

⚠️ 此操作会删除所有设置、会话历史和 MCP 服务器配置。

macOS/Linux/WSL:

bash
# 删除用户设置和状态
rm -rf ~/.claude
rm ~/.claude.json

# 删除项目设置(在项目目录中运行)
rm -rf .claude
rm -f .mcp.json

Windows PowerShell:

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

相关资源