Windows 安装指南
本指南帮助你在 Windows 上配置 AI 编程工具,使用 Any API 作为 API 中转服务。
Step 1: 安装 Node.js 环境
方法一:官网下载(推荐)
- 访问 https://nodejs.org
- 下载 LTS 版本的
.msi安装包 - 双击安装包,按提示完成安装
方法二:使用包管理器
powershell
# 使用 Chocolatey
choco install nodejs
# 或使用 Scoop
scoop install nodejsTIP
建议使用 PowerShell 运行以上命令。如遇权限问题,请以管理员身份运行 PowerShell。
验证安装:
powershell
node --version
npm --versionStep 2: 安装 Claude Code
powershell
npm install -g @anthropic-ai/claude-code验证安装:
powershell
claude --versionStep 3: 设置环境变量
方法一:临时设置(当前会话)
powershell
$env:ANTHROPIC_BASE_URL = "https://anyapi.pro"
$env:ANTHROPIC_AUTH_TOKEN = "your_api_key"方法二:永久设置(推荐)
powershell
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "https://anyapi.pro", "User")
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_AUTH_TOKEN", "your_api_key", "User")TIP
永久设置后需要重新打开 PowerShell 才能生效。
验证环境变量:
powershell
echo $env:ANTHROPIC_BASE_URL
echo $env:ANTHROPIC_AUTH_TOKENStep 4: 开始使用
powershell
claude也可以先进入项目目录再启动:
powershell
cd C:\Projects\my-project
claude常见问题
PowerShell 执行策略错误
powershell
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser找不到 claude 命令
- 确认安装成功:
npm list -g @anthropic-ai/claude-code - 重新打开终端窗口
- 检查 npm 全局路径是否在 PATH 中
npm 安装速度慢
使用国内镜像:
powershell
npm install -g @anthropic-ai/claude-code --registry=https://registry.npmmirror.com