掘金 人工智能 07月20日 10:29
Claude Code 最新详细安装教程
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

本文详细介绍了如何在Windows系统上直接安装和配置Claude Code,无需繁琐的WSL虚拟机设置。文章从准备工作开始,指导用户安装nvm工具、指定Node.js版本,并提供了全局安装Claude Code的命令。同时,讲解了如何配置系统环境变量以实现多用户使用,以及启动Claude Code的步骤和安全注意事项,包括信任文件确认和登录过程。最终目标是让Windows用户能够便捷地在本地环境中体验Claude Code的编码辅助功能,并提及了官方订阅与API计费两种登录方式。

✅ **Windows本地直装Claude Code:** 文章提供了一种无需WSL虚拟机即可在Windows系统上直接安装和使用Claude Code的方法,极大地简化了配置流程,让Windows用户也能便捷地享受Claude Code的编码辅助功能。

🛠️ **详细的安装配置步骤:** 从准备工作(如切换命令提示符、安装nvm、指定Node.js版本)到Claude Code的全局安装、版本检查、系统环境变量配置,再到启动和登录过程,文章提供了详尽的操作指南,并附带了关键命令和界面说明。

💡 **安全与登录方式:** 文章强调了在使用Claude Code时的安全注意事项,如审查回复内容以避免注入风险,并详细介绍了两种登录方式:通过Claude账户订阅或使用Anthropic控制台进行API计费,以及如何配置指向anyrouter.top的API Base URL。

🚀 **优化使用体验:** 提供了启动Claude Code的最佳实践,建议在项目根目录下运行,并介绍了如何配置主题模式、使用`/login`命令进行登录,以及一些实用的提示,如`/init`创建CLAUDE.md文件和`/terminal-setup`优化终端集成,旨在提升用户的使用效率和体验。

一、Windows 系统安装

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

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

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

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

1. 准备工作

1. 打开命令提示符

2. 安装 nvm 工具

3. 安装 node 版本

nvm install 18# 或者安装最新的22# nvm install 22

4. 使用 node 版本

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

nvm use 18# 或者使用最新版本22nvm use 22

2. 安装 Claude Code

2.1 全局安装 Claude Code

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

2.2 检查安装版本

C:\Users\Administrator>claude --version1.0.53 (Claude Code)

2.3 配置系统常量

 ANTHROPIC_AUTH_TOKEN=sk-eYCNf0I6ceXXXXXXXXXXXXXXXXXXXXXX ANTHROPIC_BASE_URL=https://anyrouter.top

2.4 启动 Claude Code

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

╭──────────────────────────╮│ ✻ 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的时候,注意审查回复的内容,避免出现注入的风险。

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

╭──────────────────────────╮│ ✻ 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 信任文件确认

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

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

╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮│                                                                                                                                                                                                               ││ 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 运行登录命令

╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮│                                                                                                                ││ 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 登录成功

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

╭──────────────────────────╮│ ✻ 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

Paste code here if prompted > 这里输入下面的Code内容

4. 正式使用

╭───────────────────────────────────────────────────╮│ ✻ 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 的本地安装,如果这篇文章对您有所帮助,欢迎您多多分享给身边的人,也能享受到技术红利,多给自己留些上班摸鱼的时间。😂😂

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

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

Claude Code Windows安装 AI编程 开发工具
相关文章