发布于 2025 年 7 月 16 日,星期三
Windows平台下Claude Code的安装配置步骤与使用技巧,包括环境准备、依赖项安装、常见错误解决方案及优化设置。内容涵盖从下载到运行的全流程操作指南,针对Windows系统特性提供兼容性调整建议,重点解决权限管理、路径配置、依赖冲突等典型问题,同时分享命令行参数调优和插件扩展方法,帮助开发者高效利用Claude Code进行项目开发。
要在 Windows 上使用 Claude Code,首先需要安装 WSL2(Windows Subsystem for Linux)。
启用 Windows 功能
启动或关闭 Windows 功能
Virtual machine platform
(虚拟机平台)、适用于 Linux 的 Windows 子系统
配置 WSL,打开 PowerShell
# 设置 WSL 默认版本为 2wsl --set-default-version 2# 安装wsl --install# 更新 WSL 并使用网页下载(如果已安装 Ubuntu, 则可能需要更新)# 添加 `--web-download` 参数可以防止因国内网络导致的各种下载问题wsl --update --web-download
等待安装完成
电脑搜索:Ubuntu 并打开,执行下面的命令
# 安装NVMcurl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash# 重新刷新加载配置source ~/.bashrc# 安装Node.js 最新版本nvm install --ltsnvm use --lts# 验证安装node --version # 显示 v22.x.xnpm --version # 显示 10.x.x
npm install -g @anthropic-ai/claude-code# 验证安装claude --version
# 打开 .bashrc 配置文件nano ~/.bashrc# 配置具体的 API 和 Tokenexport ANTHROPIC_AUTH_TOKEN=sk-...export ANTHROPIC_BASE_URL=https://anyrouter.top# 重新加载配置source ~/.bashrc
claude
回车即可npm WARN using --force Recommended protections disabled.npm WARN cleanup Failed to remove some directories [npm WARN cleanup [npm WARN cleanup 'C:\\Users\\<USER>\\AppData\\Roaming\\npm\\node_modules\\@anthropic-ai\\claude-code',npm WARN cleanup [Error: EPERM: operation not permitted, rmdir 'C:\Users\<USER>\AppData\Roaming\npm\node_modules\@anthropic-ai\claude-code\vendor\sdk\src\internal'] {npm WARN cleanup errno: -4048,npm WARN cleanup code: 'EPERM',npm WARN cleanup syscall: 'rmdir',npm WARN cleanup path: 'C:\\Users\\<USER>\\AppData\\Roaming\\npm\\node_modules\\@anthropic-ai\\claude-code\\vendor\\sdk\\src\\internal'npm WARN cleanup }npm WARN cleanup ]npm WARN cleanup ]npm ERR! code 1npm ERR! path C:\Users\<USER>\AppData\Roaming\npm\node_modules\@anthropic-ai\claude-codenpm ERR! command failednpm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node scripts/preinstall.jsnpm ERR! Error: Claude Code is not supported on Windows.npm ERR! Claude Code requires macOS or Linux to run properly.npm ERR! If you are using WSL (Windows Subsystem for Linux):npm ERR! 1. Make sure you are running npm install from within the WSL terminal, not from PowerShell or CMDnpm ERR! 2. If you're still seeing this message in WSL, your environment may be incorrectly reporting as Windows
npm ERR! Please visit https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/overview#check-system-requirements for troubleshooting information.
建议:使用 NVM 安装,可能避免一些安装问题
2025 最新!独立开发者穷鬼套餐https://mp.weixin.qq.com/s/uqxi-r9y_SkP0mGLybsp8w
就这样用 Vibe Coding 又完成了一个项目https://mp.weixin.qq.com/s/ltVeV4ACuK5YX0D1XJ4Z7Q
最近 Vibe Coding 的实践经验分享https://mp.weixin.qq.com/s/RwH28NideOpfB90Ji09bpQ
分享一款 AI 自动生成流程图的工具https://mp.weixin.qq.com/s/2cDJr9Hf2lcrvsMGgw_LtQ
一个 Cursor mdc 自动生成器,基于 Gemini 2.5,很实用!https://mp.weixin.qq.com/s/lV34CiMf32M8EaQY49NF2Q
这个 361k Star 的项目,一定要收藏!https://mp.weixin.qq.com/s/lUqojQDTOmrxqYIle21cYw
搞定 XLSX 预览?别瞎找了,这几个库(尤其最后一个)真香!https://mp.weixin.qq.com/s/6GdfVnmu30Ki1XeadzuuRg
实战分享】10 大支付平台全方面分析,独立开发必备!https://mp.weixin.qq.com/s/Nf1K_8KHLJH_aegL74NXFA
关于 MCP,这几个网站你一定要知道!https://mp.weixin.qq.com/s/pR76UwvsJQyRE__LVx6Whg
做 Docx 预览,一定要做这个神库!!https://mp.weixin.qq.com/s/gwTbX3hM_GPdDVg3W1ftAQ
【完整汇总】近 5 年 JavaScript 新特性完整总览https://mp.weixin.qq.com/s/f5pIdyY8grx9t6qYxMgR1w
关于 Node,一定要学这个 10+万 Star 项目!https://mp.weixin.qq.com/s/RGFQbqzmrY1NVkdUsQcMBw