AI中转 使用文档
api-a-i.xyz

macOS 安装 Claude Code

在 macOS 系统上安装和配置 Claude Code

系统要求

💡macOS 首次运行 git 时会自动提示安装 Xcode Command Line Tools,按提示操作即可。

1. 安装 Node.js

方式一:使用 fnm 安装(推荐)

# 安装 fnm
curl -fsSL https://fnm.vercel.app/install | bash

# 安装最新 LTS 版本
fnm install --lts
node -v

方式二:使用 Homebrew

brew install node

2. 安装 Claude Code

npm install -g @anthropic-ai/claude-code

3. 配置环境变量

Zsh 用户(macOS 默认):

echo 'export ANTHROPIC_AUTH_TOKEN="sk-你的令牌"' >> ~/.zshrc
echo 'export ANTHROPIC_BASE_URL="https://api-a-i.xyz"' >> ~/.zshrc
source ~/.zshrc

Bash 用户:

echo 'export ANTHROPIC_AUTH_TOKEN="sk-你的令牌"' >> ~/.bash_profile
echo 'export ANTHROPIC_BASE_URL="https://api-a-i.xyz"' >> ~/.bash_profile
source ~/.bash_profile
← Windows 安装Linux 安装 →