Skip to content

Windows 安装指南

本指南帮助你在 Windows 上配置 AI 编程工具,使用 Any API 作为 API 中转服务。

Step 1: 安装 Node.js 环境

方法一:官网下载(推荐)

  1. 访问 https://nodejs.org
  2. 下载 LTS 版本的 .msi 安装包
  3. 双击安装包,按提示完成安装

方法二:使用包管理器

powershell
# 使用 Chocolatey
choco install nodejs

# 或使用 Scoop
scoop install nodejs

TIP

建议使用 PowerShell 运行以上命令。如遇权限问题,请以管理员身份运行 PowerShell。

验证安装:

powershell
node --version
npm --version

Step 2: 安装 Claude Code

powershell
npm install -g @anthropic-ai/claude-code

验证安装:

powershell
claude --version

Step 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_TOKEN

Step 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

API 中转站