【此步骤在桌面】下载git
访问 https://git-scm.com/downloads/win,安装时全都下一步,不要修改路径
在 Windows 系统上安装官方 Claude Code CLI
此流程100%使用官方原版安装包,确保服务体验与官方完全一致
Windows 10 (版本 1809 / build 17763) 及以上
访问 https://git-scm.com/downloads/win,安装时全都下一步,不要修改路径
访问 https://nodejs.org/zh-cn/download,安装时全都下一步,不要修改路径
打开Windows PowerShell(蓝色图标),执行以下命令验证安装情况:
PS> node -v PS> npm -v
若提示「No suitable shell found」,是git没装好。请将 CLAUDE_CODE_GIT_BASH_PATH=C:\Program Files\git\bin\bash.exe 设置到系统环境变量中,重启终端再试。依旧无效,重装git,重启终端后再试
PS> npm uninstall -g @anthropic-ai/claude-code
PS> npm install -g @anthropic-ai/claude-code
在我的电脑,右键属性,然后找到高级系统设置,然后找到环境变量,点击环境变量,弹出一个窗口,然后在系统变量里面新建以下二个环境变量:
ANTHROPIC_BASE_URL,变量值:https://apirelay.aiserverapp.comANTHROPIC_API_KEY,变量值:你的密钥重启Windows PowerShell后运行以下命令,确认安装成功
PS> claude -v
安装完成后,您可以在任何项目目录中开始使用 Claude Code:
# 导航到您的项目 $ cd your-project-folder # 启动 Claude Code $ claude
* Welcome to Claude Code Unable to connect to Anthropic services Failed to connect to api.anthropic.com: ERR_BAD_REQUEST Please check your internet connection and network settings. Note: Claude Code might not be available in your country. Check supported countries at https://anthropic.com/supported-countries PS D:\PythonDev\ClaudeCode>
API Error (401 {"error":"Unauthorized - Invalid token"}) · Retrying in 1 seconds... (attempt 1/10) API Error (401 {"error":"Unauthorized - Invalid token"}) · Retrying in 1 seconds... (attempt 2/10) API Error (401 {"error":"Unauthorized - Invalid token"}) · Retrying in 2 seconds... (attempt 3/10) API Error (401 {"error":"Unauthorized - Invalid token"}) · Retrying in 5 seconds... (attempt 4/10) API Error (401 {"error":"Unauthorized - Invalid token"}) · Retrying in 8 seconds... (attempt 5/10) API Error (401 {"error":"Unauthorized - Invalid token"}) · Retrying in 18 seconds... (attempt 6/10) API Error (401 {"error":"Unauthorized - Invalid token"}) · Retrying in 34 seconds... (attempt 7/10) API Error (401 {"error":"Unauthorized - Invalid token"}) · Retrying in 38 seconds... (attempt 8/10) API Error (401 {"error":"Unauthorized - Invalid token"}) · Retrying in 38 seconds... (attempt 9/10)
修改「C:\users\你的用户\.claude.json」文件,在最外层json中增加 "hasCompletedOnboarding": true