搞定了kimi k2+ claude code在windows下原生使用
Windows下使用claude code的障碍是shell环境(命令行),非posix风格shell无法正常让claude code读取到url和key, 导致无法使用。解决问题的本质是使用符合posix风格的shell环境,我们采用Windows自己的windows terminal (需要从windows store中下载)。
本质: claude code + windows terminal + git for windows (需要使用它的bash程序)
注意:需要安装 git for windows, windows terminal 需要调用git 目录下的bash.exe
如果你的git安装目录不是默认路径,需要设置环境变量指定位置:(例 如)
CLAUDE_CODE_GIT_BASH_PATH = C:\soft\apps\git\current\bin\bash.exe (这个路径与你的实际安装环境对应,不要照抄。默认安装git for windows 无需设置此环境变量)
windows
1. 安装 nodejs程序 (网上搜索windows安装包)
https://nodejs.org/dist/v22.17.1/node-v22.17.1-x64.msi
2. 安装 claude-code
npm install -g @anthropic-ai/claude-code
claude --version
3. 设置windows 环境变量
在系统高级设置中添加环境变量
ANTHROPIC_API_KEY 及 ANTHROPIC_BASE_URL
ANTHROPIC_BASE_URL为 https://api.moonshot.cn/anthropic/ ,key为你的api_key (从Moonshot AI - 开放平台 申请,需要充值50块钱,否则会卡)
4. 安装git for windows
https://github.com/git-for-windows/git/releases/download/v2.50.1.windows.1/Git-2.50.1-64-bit.exe
5. 在Windows store中安装windows terminal
使用windows terminal 的命令行运行
输入claude then enjoy!