系统:win11
内存:4G+
Node.js:18.0+
Git:2.23+
Claude Code CLI:2.1.81
1.安装 Claude Code CLI
以管理员身份打开 PowerShell 安装 Claude Code CLI
# 安装最新版本
npm install -g @anthropic-ai/claude-code
# 查看安装的版本号
claude --version首次安装
PS C:\Users\Su> npm install -g @anthropic-ai/claude-code
added 2 packages in 12s
PS C:\Users\Su> claude
Welcome to Claude Code v2.1.81
…………………………………………………………………………………………………………………………………………………………
* █████▓▓░
* ███▓░ ░░
░░░░░░ ███▓░
░░░ ░░░░░░░░░░ ███▓░
░░░░░░░░░░░░░░░░░░░ * ██▓░░ ▓
░▓▓███▓▓░
* ░░░░
░░░░░░░░
░░░░░░░░░░░░░░░░
█████████ *
██▄█████▄██ *
█████████ *
…………………█ █ █ █………………………………………………………………………………………………………………
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提示 Unable to connect to Anthropic services,这是因为首次启动会让你登录 Claude 官网,进行登录授权,如果成功登录则会保存登录凭证,下一次直接启动
2.配置代理网络和API Key
修改 C:\Users\Su\.claude 下的 setting.json 文件(没有则自行创建),默认内容如下:
{
"permissions": {
"allow": []
}
}如果你只使用国产大模型,则无需配置代理
配置代理可以登录 claude官网,将代理地址替换为你实际使用的本地代理端口(如 7890 为 Clash 等工具的默认端口,我这里为 7897)。
{
"env": {
"HTTP_PROXY": "http://127.0.0.1:7897",
"HTTPS_PROXY": "http://127.0.0.1:7897"
}
}鉴于使用国外大模型需要能够访问外网,这里仅仅演示如何配置国产大模型(美团的LongCat),先获取 LongCat API Keys ,配置后内容如下,你也可以使用 DeepSeek API Keys,只不过前者提供了大量的免费额度
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "your_longcat_api_key",
"ANTHROPIC_BASE_URL": "https://api.longcat.chat/anthropic",
"ANTHROPIC_MODEL": "LongCat-Flash-Thinking-2601",
"ANTHROPIC_SMALL_FAST_MODEL": "LongCat-Flash-Thinking-2601",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "LongCat-Flash-Thinking-2601",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "LongCat-Flash-Thinking-2601",
"CLAUDE_CODE_MAX_OUTPUT_TOKENS": "6000",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": 1
},
"permissions": {
"allow": [],
"deny": []
}
}由于 DeepSeek V4 的性价比非常高,所以更推荐接入 DeepSeek V4
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "your_deespeek_api_key",
"ANTHROPIC_BASE_URL": "https://api.deepseek.com/anthropic",
"ANTHROPIC_MODEL": "deepseek-v4-pro[1m]",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "deepseek-v4-pro[1m]",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "deepseek-v4-pro[1m]",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "deepseek-v4-flash",
"CLAUDE_CODE_SUBAGENT_MODEL": "deepseek-v4-flash",
"CLAUDE_CODE_MAX_OUTPUT_TOKENS": "32000",
},
"permissions": {
"allow": [],
"deny": []
}
}参数说明如下,其中 1m 表示使用 1M token 的上下文长度,默认为 200K 所以需要特别指定
3.运行
配置完毕,输入 claude 运行 Claude Code CLI,首次运行会让你选择一个主题,后续在 CLI 中输\theme 也可以切换
Welcome to Claude Code v2.1.81
…………………………………………………………………………………………………………………………………………………………
* █████▓▓░
* ███▓░ ░░
░░░░░░ ███▓░
░░░ ░░░░░░░░░░ ███▓░
░░░░░░░░░░░░░░░░░░░ * ██▓░░ ▓
░▓▓███▓▓░
* ░░░░
░░░░░░░░
░░░░░░░░░░░░░░░░
█████████ *
██▄█████▄██ *
█████████ *
…………………█ █ █ █………………………………………………………………………………………………………………
Let's get started.
Choose the text style that looks best with your terminal
To change this later, run /theme
❯ 1. Dark mode ✔
2. Light mode
3. Dark mode (colorblind-friendly)
4. Light mode (colorblind-friendly)
5. Dark mode (ANSI colors only)
6. Light mode (ANSI colors only)
╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
1 function greet() {
2 console.log("Hello, World!");
-
2 console.log("Hello, Claude!");
+
3 }
╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
Syntax highlighting available only in native build点击回车确认即可
╭─── Claude Code v2.1.81 ──────────────────────────────────────────────────────────────────────────────────────────────╮
│ │ Tips for getting started │
│ Welcome back! │ Run /init to create a CLAUDE.md file with instructions for Cla… │
│ │ Note: You have launched claude in your home directory. For the… │
│ ▐▛███▜▌ │ ─────────────────────────────────────────────────────────────── │
│ ▝▜█████▛▘ │ Recent activity │
│ ▘▘ ▝▝ │ No recent activity │
│ │ │
│ LongCat-Flash-Thinking-2601 · API Usage Billing │ │
│ C:\Users\Su │ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
↑ Opus now defaults to 1M context · 5x more room, same pricing
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
❯ Try "how do I log an error?"
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────Claude Code 在启动和运行时会 自动检查更新,后台下载完成后,下次启动即生效,如果你不需要自动更新,则需要在 ~\.claude\setting.json 文件中进行配置
{
"env": {
"DISABLE_AUTOUPDATER": "1" // 设为 "1" 禁用自动更新,"0" 或删除该行则恢复自动更新
}
}后续手动更新,只需要在 PowerShell 中输入如下命令
claude update4.配置免登录验证
最后在用户目录下新建 ~/.claude.json(如果已经存在可直接修改),加入如下配置项,跳过 Claude Code 的登录验证
"hasCompletedOnboarding": true
评论区