Claude Code 安装配置全攻略
1️⃣ 安装 Node.js(已安装可跳过)
确保 Node.js 版本 ≥ 18.0
1. # Ubuntu / Debian 用户
2. curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo bash -
3. sudo apt-get install -y nodejs
4. node --version
5.
6. # macOS 用户
7. sudo xcode-select --install
8. /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
9. brew install node
10. node --version
2️⃣ 安装 Claude Code
1. npm install -g @anthropic-ai/claude-code
2. claude --version
3️⃣ 开始使用
获取 Auth Token: ANTHROPIC_AUTH_TOKEN :注册后在 API令牌 页面点击 添加令牌 获得(以 sk- 开头)
名称随意,额度建议设为无限额度,其他保持默认设置即可
API地址: ANTHROPIC_BASE_URL:https://anyrouter.top 是本站的 API 服务地址,与主站地址相同
在您的项目目录下运行:
1. cd your-project-folder
2. export ANTHROPIC_AUTH_TOKEN=sk-...
3. export ANTHROPIC_BASE_URL=https://anyrouter.top
4. claude
运行后
选择你喜欢的主题 + Enter
确认安全须知 + Enter
使用默认 Terminal 配置 + Enter
信任工作目录 + Enter
开始在终端里和你的 AI 编程搭档一起写代码吧!🚀
4️⃣ 配置环境变量(推荐)
为避免每次重复输入,可将环境变量写入 bash_profile 和 bashrc:
1. echo -e '\n export ANTHROPIC_AUTH_TOKEN=sk-...' >> ~/.bash_profile
2. echo -e '\n export ANTHROPIC_BASE_URL=https://anyrouter.top' >> ~/.bash_profile
3. echo -e '\n export ANTHROPIC_AUTH_TOKEN=sk-...' >> ~/.bashrc
4. echo -e '\n export ANTHROPIC_BASE_URL=https://anyrouter.top' >> ~/.bashrc
5. echo -e '\n export ANTHROPIC_AUTH_TOKEN=sk-...' >> ~/.zshrc
6. echo -e '\n export ANTHROPIC_BASE_URL=https://anyrouter.top' >> ~/.zshrc
重启终端后,直接使用:
1. cd your-project-folder
2. claude
即可使用 Claude Code

浙公网安备 33010602011771号