Claude Code 完全安装指南
Claude Code 是 Anthropic 推出的 AI 编程助手,本文详细介绍如何安装和配置 Claude Code。
一、系统要求
- 操作系统:Windows 10/11、macOS、Linux
- Node.js:18.x 或更高版本
- npm:9.x 或更高版本
二、安装步骤
1. 安装 Node.js
# Windows(使用 scoop)
scoop install nodejs
# macOS
brew install node
# Linux
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs2. 安装 Claude Code
npm install -g @anthropic-ai/claude-code3. 验证安装
claude --version三、配置 API Key
# 设置环境变量
export ANTHROPIC_API_KEY="your-api-key"
# 或者使用配置文件
claude config set api_key your-api-key四、基本使用
# 启动 Claude Code
claude
# 在项目目录中使用
cd your-project
claude
# 直接提问
claude "如何优化这段代码?"五、常见问题
- 安装失败:检查 Node.js 版本是否满足要求
- API Key 无效:确认 API Key 是否正确且有余额
- 网络问题:检查代理设置或使用 VPN