ubuntu20 安装claude-code + deepseek v4 pro
·
国内直接安装claude-code,会被系统识别出IP在中国大陆,不返回安装脚本,而是返回一个“App unavailable in region”的提示网页,此时需要通过npm绕过限制。
npm通常是和nodejs打包的,安装claude-code至少需要node版本是V18以上,我的系统中有一个低版本的node,需要先卸载。
ccc@ccc-QingtianT510A-15ARR:~$ node --version
v10.19.0
ccc@ccc-QingtianT510A-15ARR:~$ sudo apt remove --purge nodejs npm
ccc@ccc-QingtianT510A-15ARR:~$ sudo apt autoremove
重新安装。
ccc@ccc-QingtianT510A-15ARR:~$ curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
ccc@ccc-QingtianT510A-15ARR:~$ sudo apt-get install -y nodejs
ccc@ccc-QingtianT510A-15ARR:~$ node --version
v22.22.2
ccc@ccc-QingtianT510A-15ARR:~$ npm --version
10.9.7
安装claude-code。只为当前用户安装,先创建并配置目录。
ccc@ccc-QingtianT510A-15ARR:~$ mkdir -p ~/.npm-global
ccc@ccc-QingtianT510A-15ARR:~$ npm config set prefix "$HOME/.npm-global"
ccc@ccc-QingtianT510A-15ARR:~$ echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.bashrc
ccc@ccc-QingtianT510A-15ARR:~$ source ~/.bashrc
安装:
ccc@ccc-QingtianT510A-15ARR:~$ npm install -g @anthropic-ai/claude-code
added 2 packages in 8s
ccc@ccc-QingtianT510A-15ARR:~$
直接运行claude,会报错,提示网络问题。先通过环境变量解决。使用deepseek的api做中转。将自己的deepseek上的信息配置到如下两个环境变量中。
# 配置 API 地址,deepseek对应claude-code的目前是:https://api.deepseek.com/anthropic,可以在deepseek API文档中查询到。
echo 'export ANTHROPIC_BASE_URL="https://api.deepseek.com/anthropic"' >> ~/.bashrc
# 配置 API 密钥,deepseek上创建的密钥。
echo 'export ANTHROPIC_AUTH_TOKEN="sk-***你的密钥"' >> ~/.bashrc
# 如果用的是 DeepSeek,建议也指定默认模型
echo 'export ANTHROPIC_MODEL="deepseek-v4-pro"' >> ~/.bashrc
# 让配置立即生效
source ~/.bashrc
运行claude
ccc@ccc-QingtianT510A-15ARR:~$ claude
Welcome to Claude Code v2.1.152
..........................................................
* █████▓▓░
* ███▓░ ░░
░░░░░░ ███▓░
░░░ ░░░░░░░░░░ ███▓░
░░░░░░░░░░░░░░░░░░░ * ██▓░░ ▓
░▓▓███▓▓░
* ░░░░
░░░░░░░░
░░░░░░░░░░░░░░░░
█████████ *
██▄█████▄██ *
█████████ *
.......█ █ █ █..........................................
Let's get started.
Choose the text style that looks best with your terminal
To change this later, run /theme
1. Auto (match terminal)
❯ 2. Dark mode ✔
3. Light mode
4. Dark mode (colorblind-friendly)
5. Light mode (colorblind-friendly)
6. Dark mode (ANSI colors only)
7. Light mode (ANSI colors only)
╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
1 function greet() {
2 - console.log("Hello, World!");
2 + console.log("Hello, Claude!");
3 }
╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
Syntax theme: Monokai Extended (ctrl+t to disable)
配置完整的模型,/exit 退出claud。
使用 nano ~/.claude/settings.json 修改模型配置并保存,主模型设置为deepseek-v4-flash; opus 模型配置为deepseek-v4-pro;其他都配置为deepseek-v4-flash。 这里主要是为了省钱,如果不在乎token,可以都设置为deepseek-v4-pro。
ccc@ccc-QingtianT510A-15ARR:~$ cat ~/.claude/settings.json
{
"theme": "dark",
"env": {
"ANTHROPIC_BASE_URL": "https://api.deepseek.com/anthropic",
"ANTHROPIC_AUTH_TOKEN": "sk-xxxxxxxxxxxxxxx你的密钥",
"ANTHROPIC_MODEL": "deepseek-v4-flash",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "deepseek-v4-pro",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "deepseek-v4-flash",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "deepseek-v4-flash"
}
}
重新启动claude,/model 查询模型配置生效情况。
ccc@ccc-QingtianT510A-15ARR:~$ claude
╭─── Claude Code v2.1.152 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │ Tips for getting started │
│ Welcome back! │ Run /init to create a CLAUDE.md file with instructions for Claude │
│ │ Note: You have launched claude in your home directory. For the best experience, launch it in a project directory instead. │
│ ▐▛███▜▌ │ ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── │
│ ▝▜█████▛▘ │ What's new │
│ ▘▘ ▝▝ │ `/code-review --fix` now applies review findings to your working tree after the review, surfacing reuse, simplification, and efficiency suggestions; `/sim… │
│ │ Skills and slash commands can now set `disallowed-tools` in frontmatter to remove tools from the model while the skill is active │
│ deepseek-v4-flash · API Usage Billing │ Added `/reload-skills` command to re-scan skill directories without restarting the session │
│ /home/ccc │ /release-notes for more │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
❯ /model
⎿ Kept model as deepseek-v4-flash
❯ /model
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Select model
Switch between Claude models. Applies to this session only. For other/previous model names, specify with --model.
1. Default (recommended) Use the default model (currently deepseek-v4-pro[1m]) · $5/$25 per Mtok
2. deepseek-v4-pro Custom Opus model
3. deepseek-v4-flash Custom Sonnet model
4. deepseek-v4-flash Custom Haiku model
❯ 5. deepseek-v4-flash ✔ Custom model
● High effort (default) ←/→ to adjust
Enter to confirm · d to set as default for new sessions · Esc to cancel
配置了settings.json文件,前面临时配置的bashrc 可以根据个人需要删除。
更多推荐

所有评论(0)