方式一:npm 安装(任意系统,需要 Node.js 18+)
node -v # 需要 v18 以上
npm install -g @anthropic-ai/claude-code
claude --version
如果 npm install -g 在 macOS / Linux 上报 EACCES 权限错误,不要用 sudo。改用 npm config set prefix ~/.npm-global,然后把 ~/.npm-global/bin 加进 PATH。Windows 上请在普通(非管理员)终端里安装。Node.js 版本过低是安装失败最常见的原因,用 nvm 装一个 LTS 版本最省事。
方式二:官方一键安装脚本(不需要 Node.js)
# macOS / Linux / WSL
curl -fsSL https://claude.ai/install.sh | bash
# Windows PowerShell
irm https://claude.ai/install.ps1 | iex
# Windows CMD
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
脚本会下载一个独立的可执行文件并自动更新,不依赖 Node 版本,适合服务器、容器和不想装 Node 的机器。
Windows 安装 Claude Code 的注意事项
Claude Code 原生支持 Windows 10/11(PowerShell 或 Git Bash),也可以在 WSL 里运行;对于按 Unix 习惯组织的项目,WSL 体验更顺。npm 安装后如果提示找不到 claude 命令,先关掉终端重新打开,让 PATH 生效;仍不行就运行 npm config get prefix,把它输出目录下的 bin 加进 PATH。
方式三:桌面应用或 IDE 插件
Claude 桌面应用内置了 Claude Code;VS Code 和 JetBrains 插件在第一次启动时会自动安装 CLI。适合不想碰终端的人,功能和命令行版本一致。
安装后:接入本网关,两行配置
export ANTHROPIC_BASE_URL=https://aiprimetech.io
export ANTHROPIC_API_KEY=你的网关密钥
claude
把这两行写进 ~/.zshrc、~/.bashrc 或 PowerShell 配置文件。进入会话后输入 /status 可以看到当前连接的地址和密钥。注意 ANTHROPIC_BASE_URL 填裸域名,不要加 /v1——SDK 会自己拼接 /v1/messages,多加一层会 404。
更新与卸载
claude update # 一键脚本 / 自更新
npm update -g @anthropic-ai/claude-code # npm 安装的更新方式
npm uninstall -g @anthropic-ai/claude-code # 卸载
安装成功但启动不了?
command not found→ PATH 问题:重开终端,或把 npm 全局 bin 目录加进 PATH。- Node 版本报错 → 需要 Node.js 18 以上,
node -v检查;或者改用一键脚本绕过 Node。 - 首次启动卡住 → 多半是网络或代理:设置 HTTPS_PROXY,或直接使用网关地址(见配置页)。
- 401 / invalid key → 指向网关时必须用网关密钥,Anthropic 控制台的密钥会被拒绝。
claude doctor可以一键检查安装环境。
先免费试一下
新账户使用优惠码 CLAUDECODE 注册即可获得 $5 的 API 余额,无需绑卡——足够跑一晚上 Claude Code。同样的 Claude 模型,两行环境变量即可切换。
export ANTHROPIC_BASE_URL=https://aiprimetech.io
export ANTHROPIC_API_KEY=your_key常见问题
安装 Claude Code 需要 Node.js 吗?
只有 npm 方式需要(18 以上)。一键脚本和桌面应用都不需要 Node.js。
Claude Code 支持 Windows 吗?
支持。可以在 PowerShell、Git Bash 里原生运行,也可以在 WSL 里运行;Unix 风格的项目推荐 WSL。
没有 Claude 订阅能安装吗?
可以。安装本身免费,用 API 密钥登录即可——本网关的密钥可以直接替代。
在网关上运行 Claude Code
同样的模型,两行环境变量,积分按 7.69 倍面值充值,或选择不限量套餐。 新账户使用优惠码 CLAUDECODE 可获得 $5 的 API 余额。
获取 API 密钥 查看套餐AI Prime Tech is an independent API gateway and is not affiliated with, endorsed by, or sponsored by Anthropic. “Claude” and “Claude Code” are trademarks of Anthropic. Claude Code features described here follow Anthropic’s public documentation at the time of writing and change frequently; prices and model lists on this page are read from this gateway’s live settings.