Claude Code Linux
Claude Code Linux 使用教程。
当前建议分组:
AppClaude当前建议模型:claude-opus-4-6
(一) 安装 Node.js 环境
Linux 安装方法
方法一:NodeSource
1curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
2sudo apt-get install -y nodejs
方法二:系统包管理器
1sudo apt update
2sudo apt install nodejs npm
验证安装:
1node --version
2npm --version
(二) 安装 Claude Code
1npm install -g @anthropic-ai/claude-code --registry=https://registry.npmmirror.com
如果你当前用户没有全局安装权限,可以用:
1sudo npm install -g @anthropic-ai/claude-code --registry=https://registry.npmmirror.com
验证安装:
1claude --version
(三) 配置 Claude Code
方法一:写入 shell 配置
如果你用的是 bash:
1echo 'export ANTHROPIC_BASE_URL="https://4router.net"' >> ~/.bashrc
2echo 'export ANTHROPIC_AUTH_TOKEN="sk-REPLACE_ME"' >> ~/.bashrc
3source ~/.bashrc
如果你用的是 zsh:
1echo 'export ANTHROPIC_BASE_URL="https://4router.net"' >> ~/.zshrc
2echo 'export ANTHROPIC_AUTH_TOKEN="sk-REPLACE_ME"' >> ~/.zshrc
3source ~/.zshrc
方法二:编辑 ~/.claude/settings.json
1{
2 "env": {
3 "ANTHROPIC_BASE_URL": "https://4router.net",
4 "ANTHROPIC_AUTH_TOKEN": "sk-REPLACE_ME",
5 "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
6 }
7}
(四) 开始使用 Claude Code
1claude
第一次建议先输入:
1如果你已经接到 4Router,请只回复:AppClaude 已连接
(五) 常见问题
- 全局安装报权限错误:优先用
sudo,或者把 npm 全局目录切到用户目录。 - 环境变量不生效:重新打开终端,或者手动执行
source ~/.bashrc。 - 鉴权失败:确认
ANTHROPIC_AUTH_TOKEN里的 Key 没有复制错。 - Claude 模型请求失败:先去控制台确认当前令牌能否使用
AppClaude分组。