主题
设置 Claude Code
系统要求
- 操作系统: macOS 10.15+、Ubuntu 20.04+/Debian 10+ 或 Windows 10+(带 WSL 1、WSL 2 或 Git for Windows)
- 硬件: 4GB+ RAM
- 软件: Node.js 18+(仅 NPM 安装需要)
- 网络: 认证和 AI 处理需要互联网连接
- Shell: 在 Bash、Zsh 或 Fish 中效果最佳
标准安装
原生安装(推荐)
bash
# macOS, Linux, WSL
curl -fsSL https://claude.ai/install.sh | bash
# Windows PowerShell
irm https://claude.ai/install.ps1 | iex
# Windows CMD
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmdHomebrew
bash
brew install --cask claude-codeNPM
bash
npm install -g @anthropic-ai/claude-code安装完成后,导航到您的项目并启动 Claude Code:
bash
cd your-awesome-project
claude认证选项
- Claude Console: 默认选项。通过 Claude Console 连接并完成 OAuth 过程。
- Claude App(Pro 或 Max 计划): 订阅 Claude 的 Pro 或 Max 计划。
- 企业平台: 配置 Claude Code 以使用 Amazon Bedrock 或 Google Vertex AI。
Windows 设置
选项 1: WSL 中的 Claude Code
支持 WSL 1 和 WSL 2。
选项 2: 使用 Git Bash 在本机 Windows 上的 Claude Code
需要 Git for Windows。
对于便携式 Git 安装:
powershell
$env:CLAUDE_CODE_GIT_BASH_PATH="C:\Program Files\Git\bin\bash.exe"替代安装方法
本机安装选项
本机安装是推荐的方法,提供:
- 一个自包含的可执行文件
- 无 Node.js 依赖
- 改进的自动更新程序稳定性
高级安装选项:
bash
# 安装稳定版本(默认)
curl -fsSL https://claude.ai/install.sh | bash
# 安装最新版本
curl -fsSL https://claude.ai/install.sh | bash -s latest
# 安装特定版本号
curl -fsSL https://claude.ai/install.sh | bash -s 1.0.58NPM 安装
bash
npm install -g @anthropic-ai/claude-code不要使用 sudo npm install -g,因为这可能导致权限问题和安全风险。
更新 Claude Code
自动更新
Claude Code 自动保持自身最新状态。
禁用自动更新:
bash
export DISABLE_AUTOUPDATER=1手动更新
bash
claude update