大家好,我是 Immerse,一名独立开发者、内容创作者。
https://yaolifeng.com
也同步更新。我会在这里分享关于编程
、独立开发
、AI
、出海
、个人思考
等内容。
如果本文对您有所帮助,欢迎动动小手指一键三连(点赞
、评论
、转发
),给我一些支持和鼓励,谢谢!
要在 Windows 上使用 Claude Code,首先需要安装 WSL2(Windows Subsystem for Linux)。
启动或关闭 Windows 功能
Virtual machine platform
(虚拟机平台)、适用于 Linux 的 Windows 子系统
# 设置 WSL 默认版本为 2
wsl --set-default-version 2
# 安装
wsl --install
# 更新 WSL 并使用网页下载(如果已安装 Ubuntu, 则可能需要更新)
# 添加 `--web-download` 参数可以防止因国内网络导致的各种下载问题
wsl --update --web-download
# 安装NVM
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
# 重新刷新加载配置
source ~/.bashrc
# 安装Node.js 最新版本
nvm install --lts
nvm use --lts
# 验证安装
node --version # 显示 v22.x.x
npm --version # 显示 10.x.x
npm install -g @anthropic-ai/claude-code
# 验证安装
claude --version
# 打开 .bashrc 配置文件
nano ~/.bashrc
# 配置具体的 API 和 Token
export ANTHROPIC_AUTH_TOKEN=sk-...
export ANTHROPIC_BASE_URL=https://anyrouter.top
# 重新加载配置
source ~/.bashrc
claude
回车即可alt text
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 1
npm ERR! path C:\Users\<USER>\AppData\Roaming\npm\node_modules\@anthropic-ai\claude-code
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node scripts/preinstall.js
npm 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 CMD
npm 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 安装,可能避免一些安装问题
[1]
Claude Code 在 Windows 系统中安装全流程教学: https://www.bilibili.com/video/BV1mpMizQEUS