claude code
any router可以领100美金额度的api-key:https://anyrouter.top/register?aff=K6Cx
1.相关网站
1.官方网站:https://docs.anthropic.com/en/docs/claude-code/overview
2.其他网站:https://www.anthropic.com/engineering/claude-code-best-practices
2.claude code 部署
参照文档:https://www.bilibili.com/read/cv42273794
api网站:https://anyrouter.top/console/topup
1.WSL上安装部署
参照视频:https://www.bilibili.com/video/BV1tW42197za/?spm_id_from=333.337.search-card.all.click&vd_source=e53ea15b7b23b127af657c4cec24bef3
我当时是windows安装docker,他自动帮我安装了一个docker-desktop的linux系统,wsl2是windows自带一个软件功能
1.开启CPU虚拟化,电脑好像是默认开启,在任务管理器里看
2.启用或关闭 Windows功能中打开下面两个
3.安装linux子系统
wsl --install
下面命令显示其他可安装发行版
wsl --list --online
安装了哪些子系统
wsl --list -v
切换默认子系统
wsl --set-default Ubuntu
登陆登出子系统
wsl -d Ubuntu
exit
一些其他操作
wsl --unregister 子系统名称 #卸载子系统
wsl --export 子系统名称 压缩包名称 #导出
wsl --import 子系统名称 导入路径 压缩包路径 #导入
4.使用那个wsl创建的ubantu子系统
查看系统版本
lsb_release -a
5. 更新软件源并升级系统
sudo apt updatesudo apt upgrade
6. 安装 Node.js 和 npm
sudo apt install nodejs npm
安装完成后,检查版本:
node --versionnpm --version
7.配置 npm 全局安装目录 避免权限问题,可设置全局前缀:
npm config set prefix ~/.npm-globalecho 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrcnpm config set registry https://registry.npmmirror.comsource ~/.bashrc
8. 全局安装 Claude Code
npm install -g @anthropic-ai/claude-code
export ANTHROPIC_AUTH_TOKEN=sk-...
export ANTHROPIC_BASE_URL=https://anyrouter.top
claude --version
永久化配置
为避免每次重复输入,可将环境变量写入 bash_profile 和 bashrc:echo -e '\n export ANTHROPIC_AUTH_TOKEN=sk-...' >> ~/.bash_profile
echo -e '\n export ANTHROPIC_BASE_URL=https://anyrouter.top' >> ~/.bash_profile
echo -e '\n export ANTHROPIC_AUTH_TOKEN=sk-...' >> ~/.bashrc
echo -e '\n export ANTHROPIC_BASE_URL=https://anyrouter.top' >> ~/.bashrc
echo -e '\n export ANTHROPIC_AUTH_TOKEN=sk-...' >> ~/.zshrc
echo -e '\n export ANTHROPIC_BASE_URL=https://anyrouter.top' >> ~/.zshrc
10. 进入你的项目目录
cd /mnt/c/your/project/pathclaude
11.vscode安装WSL插件
-
在终端面板选择 WSL 终端(如 Ubuntu-24.04)
-
在 WSL 终端中输入 claude 启动 Claude Code
2.windows上直接部署claude code
新版本的claude code支持windows
我电脑之前装了nvm管理node
所以我重新装一个18版本以上的就行
nvm install 18.19.1
nvm ls
nvm use 18.19.1
nvm ls
右键此电脑一属性一高级系统设置
点击环境变量→ 在系统变量中添加
变量名:CLAUDE_CODE_GIT_BASH_PATH
变量值:D:\xuexiruanjian\Git\bin\bash.exe(根据实际安装路径调整)
windows中powershell运行
npm install -g @anthropic-ai/claude-code
右键此电脑一属性一高级系统设置
点击环境变量→ 在环境变量中添加
变量名:ANTHROPIC_BASE_URL
变量值:https://anyrouter.top
变量名:ANTHROPIC_AUTH_TOKEN
变量值:自己实际api-key
进入项目文件夹直接启动claude
VScode中使用,安装插件
退出重新进入