Claude Code 最新详细安装教程

一、Windows 系统安装

**好消息:**我们Windows用户再也不需要使用WSL虚拟机各种配置来使用 Claude Code,直接在 Windows 环境就可以直接体验到 Claude Code 编码的快乐了。

  • 可视化的桌面应用可以下载(可选):https://github.com/getAsterisk/claudia

  • **注意事項:**大家一定要提前打开魔法工具🌐,否则无法使用。

  • 大家肯定会问为什么要切换到Claude Code 而不是 Cursor?那是因为最新Cursor在抽风,给国内的IP断了,体验了一回被卡脖子的感觉🤦‍♂️,干脆就直接用Claude Code。😎😎

1. 准备工作

1. 打开命令提示符

  • 在搜索栏输入:cmd,即可出现【命令提示符】,然后按下Enter回车键即可打开。

  • 命令行工具,由于默认的是 Power Shell 无法运行 Claude Code , 所以推荐大家统一改成【命令提示符】,方便后期直接使用。(如果没有下面第二张图的,则可以忽略。)

2. 安装 nvm 工具

3. 安装 node 版本

  • **版本推荐:**18+
shell 复制代码
nvm install 18
# 或者安装最新的22
# nvm install 22

4. 使用 node 版本

如果本地开发的时候用到了多个版本的node,在使用 Claude Code时候,请先切换到能启动的版本,比如:node V18以上的版本。

shell 复制代码
nvm use 18
# 或者使用最新版本22
nvm use 22

2. 安装 Claude Code

2.1 全局安装 Claude Code

shell 复制代码
npm install -g @anthropic-ai/claude-code

2.2 检查安装版本

  • 出现具体的版本,说明安装成功。
shell 复制代码
C:\Users\Administrator>claude --version
1.0.53 (Claude Code)

2.3 配置系统常量

  • 配置系统常量主要是电脑的不同用户都可以使用。

  • 在搜索栏输入【环境变量】,即可出现【编辑系统环境变量】,然后按下 Enter 回车键即可打开。

  • 然后点击【环境变量】,就可以在【系统变量】中 新建变量了。


  • 系统常量参数如下,配置完成之后,记得点击【确定】按钮保存变量数据。

  • 大家可以提前注册账户:注册入口可以贈送100美元的額度,运气好可能还会跟我一样,多几十美元。😁🤩

shell 复制代码
 ANTHROPIC_AUTH_TOKEN=sk-eYCNf0I6ceXXXXXXXXXXXXXXXXXXXXXX

 ANTHROPIC_BASE_URL=https://anyrouter.top


2.4 启动 Claude Code

启动 Claude Code,强烈建议在项目根目录下使用。

  • 打开项目目录,然后在命令行输入: claude , 我们就可以启动成功的界面内容了。

  • **配置主题模式:**可以上下切换模式,回车键为确认。

shell 复制代码
╭──────────────────────────╮
│ ✻ Welcome to Claude Code │
╰──────────────────────────╯

 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)


 Preview
 ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
 │   1   function greet() {                                                                                                                                                                                    │
 │   2 -    console.log("Hello, World!");                                                                                                                                                                      │
 │   2 +    console.log("Hello, Claude!");                                                                                                                                                                     │
 │   3   }                                                                                                                                                                                                     │
 ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

3. Claude Code 配置

3.1 安全注意事项

提示: 在使用Claude Code的时候,注意审查回复的内容,避免出现注入的风险。

接下来我们点击回车键继续。。。

shell 复制代码
╭──────────────────────────╮
│ ✻ Welcome to Claude Code │
╰──────────────────────────╯

 Security notes:

 1. Claude can make mistakes
    You should always review Claude's responses, especially when
    running code.

 2. Due to prompt injection risks, only use it with code you trust
    For more details see:
    https://docs.anthropic.com/s/claude-code-security

 Press Enter to continue...

3.2 信任文件确认

  • 默认选择第一个,然后回车键确认即可。

  • 上下键可以切换选项,如果是非项目目录,请选择第二个退出。

shell 复制代码
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                               │
│ Do you trust the files in this folder?                                                                                                                                                                        │
│                                                                                                                                                                                                               │
│ D:\Project\Web                                                                                                                                                                                        │
│                                                                                                                                                                                                               │
│ Claude Code may read files in this folder. Reading untrusted files may lead Claude Code to behave in unexpected ways.                                                                                         │
│                                                                                                                                                                                                               │
│ With your permission Claude Code may execute files in this folder. Executing untrusted code is unsafe.                                                                                                        │
│                                                                                                                                                                                                               │
│ https://docs.anthropic.com/s/claude-code-security                                                                                                                                                             │
│                                                                                                                                                                                                               │
│ ❯ 1. Yes, proceed                                                                                                                                                                                             │
│   2. No, exit                                                                                                                                                                                                 │
│                                                                                                                                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
   Enter to confirm · Esc to exit

3.3 运行登录命令

  • 在提示框中,输入 /login
shell 复制代码
╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                │
│ Do you trust the files in this folder?                                                                         │
│                                                                                                                │
│ F:\Codes\250701-App\Desktop                                                                    │
│                                                                                                                │
│ Claude Code may read files in this folder. Reading untrusted files may lead Claude Code to behave in           │
│ unexpected ways.                                                                                               │
│                                                                                                                │
│ With your permission Claude Code may execute files in this folder. Executing untrusted code is unsafe.         │
│                                                                                                                │
│ https://docs.anthropic.com/s/claude-code-security                                                              │
│                                                                                                                │
│ ❯ 1. Yes, proceed                                                                                              │
│   2. No, exit                                                                                                  │
│                                                                                                                │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
   Enter to confirm · Esc to exit
╭─────────────────────────────────────────────────────╮
│ ✻ Welcome to Claude Code!                           │
│                                                     │
│   /help for help, /status for your current setup    │
│                                                     │
│   cwd: F:\3-Codes\250701-App\Desktop  │
╰─────────────────────────────────────────────────────╯

 Tips for getting started:

 1. Run /init to create a CLAUDE.md file with instructions for Claude
 2. Run /terminal-setup to set up terminal integration
 3. Use Claude to help with file analysis, editing, bash commands and git
 4. Be as specific as you would with another engineer for the best results

 ※ Tip: Run /terminal-setup to enable convenient terminal integration like Shift + Enter for new line and more    

╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ > Try "fix lint errors"                                                                                        │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
  ? for shortcuts                                                                   Missing API key · Run /login  

3.4 登录成功

  • 登录成功之后,我们可以选择两种计费方式,一种是官方的,一种使用Anthropic控制平台。

  • 由于我们使用的https://anyrouter.top 所以需要配置第二种,会自动跳转到官方网站,采用Google方式登录即可。

**注意事项:**如果没有配置系统变量或者没有重新打开命令提示符工具,则会出现下面的问题。重新按照前面的配置方式重新启动即可。

shell 复制代码
╭──────────────────────────╮
│ ✻ Welcome to Claude Code │
╰──────────────────────────╯

  ██████╗██╗      █████╗ ██╗   ██╗██████╗ ███████╗
 ██╔════╝██║     ██╔══██╗██║   ██║██╔══██╗██╔════╝
 ██║     ██║     ███████║██║   ██║██║  ██║█████╗
 ██║     ██║     ██╔══██║██║   ██║██║  ██║██╔══╝
 ╚██████╗███████╗██║  ██║╚██████╔╝██████╔╝███████╗
  ╚═════╝╚══════╝╚═╝  ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝
  ██████╗ ██████╗ ██████╗ ███████╗
 ██╔════╝██╔═══██╗██╔══██╗██╔════╝
 ██║     ██║   ██║██║  ██║█████╗
 ██║     ██║   ██║██║  ██║██╔══╝
 ╚██████╗╚██████╔╝██████╔╝███████╗
  ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝


 Claude Code can now be used with your Claude subscription or billed based on API usage through your Console 
 account.


 Select login method:

 ❯ 1. Claude account with subscription
    Starting at $20/mo for Pro, $100/mo for Max - Best value, predictable pricing

   2. Anthropic Console account
    API usage billing
  • 下面会出现一串权限的Code,需要复制到命令行工具里面去。
shell 复制代码
Paste code here if prompted > 这里输入下面的Code内容

4. 正式使用

  • 启动之后,出现下面的 API Base URL: https://anyrouter.top , 则代表我们配置成功了,现在可以开始使用了。
shell 复制代码
╭───────────────────────────────────────────────────╮
│ ✻ Welcome to Claude Code!                         │
│                                                   │
│   /help for help, /status for your current setup  │
│                                                   │
│   cwd: C:\Users\Administrator                     │
│                                                   │
│   ─────────────────────────────────────────────── │
│                                                   │
│   Overrides (via env):                            │
│                                                   │
│   • API Base URL: https://anyrouter.top           │
╰───────────────────────────────────────────────────╯

 Tips for getting started:

 1. Run /init to create a CLAUDE.md file with instructions for Claude
 2. Use Claude to help with file analysis, editing, bash commands and git
 3. Be as specific as you would with another engineer for the best results

 Note: You have launched claude in your home directory. For the best experience, launch it in a project directory
 instead.

 ※ Tip: Use /theme to change the color theme

╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ > Try "write a test for <filepath>"                                                                                  │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
  ? for shortcuts

恭喜您!已经完成了Claude Code 的本地安装,如果这篇文章对您有所帮助,欢迎您多多分享给身边的人,也能享受到技术红利,多给自己留些上班摸鱼的时间。😂😂

若在安装过程中有疑问的,欢迎大家留言评论❤️❤️❤️

相关推荐
星际码仔43 分钟前
理念惊艳,体验拉胯:写在Kiro初体验之后
ai编程·aws·cursor
豌豆花下猫18 小时前
Python 潮流周刊#111:Django迎来 20 周年、OpenAI 前员工分享工作体验(摘要)
后端·python·ai
Despacito0o19 小时前
ESP32S3+VSCode+PlatformIO+FreeRTOS+Arduino多核编程实战:FreeRTOS任务创建+任务调度详解
ide·vscode·编辑器
cypking19 小时前
.vscode 扩展配置
ide·vscode·编辑器
介一安全20 小时前
初探 Web 环境下的 LLM 安全:攻击原理与风险边界
安全·web安全·ai·llm·安全性测试
qiyue7721 小时前
别急还有救!Cursor国内无法使用 Claude
人工智能·ai编程·cursor
我命由我1234521 小时前
VSCode - VSCode 快速跳转标签页
开发语言·前端·ide·vscode·编辑器·html·js
葫芦和十三1 天前
破局与重构:关于 UGC 平台多身份账号体系的架构思考
架构·ai编程·领域驱动设计
Jooolin1 天前
【C++】deque的设计思想
c++·后端·ai编程