news 2026/6/10 16:15:53

ClaudeCode安装记录

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
ClaudeCode安装记录

ClaudeCode安装记录

ClaudeCode目前目前支持配置AutoGLM和Kimi;Mac版本会相对简单一点,AutoGLM配了自动化的部署脚本,Windows会稍微复杂一点,需要自己配置环境变量

1-参考网址

  • 尚硅谷ClaudeCode使用教程:https://www.bilibili.com/video/BV1vG8QzcE5X
  • MAC设置本地代理参考:https://zhuanlan.zhihu.com/p/1891348757653717263
  • 解决国家不能访问:https://blog.csdn.net/qq_35376047/article/details/150064785
  • AutoGLM直接修改-支持访问(Windows直接参考这个):https://docs.bigmodel.cn/cn/guide/develop/claude
  • Claude的命令行使用参考:https://cloud.tencent.com/developer/article/2547347
  • KIMI申请API_KEY:https://platform.moonshot.cn/console/api-keys

2-Windows安装

  • 配置环境变量

CLAUDE_CODE_GIT_BASH_PATH=git的路径:D:\TT_INSTALL+\GIT\bin\bash.exe ANTHROPIC_API_KEY:XXXXXXXXXXXXXXXXXXXXXXX ANTHROPIC_BASE_URL:https://api.moonshot.cn/anthropic
  • 安装claude-code
npm install -g @anthropic-ai/claude-code
  • 编辑C:\Users\popyu.claude.json

当前在代码中添加hasCompletedOnboarding=true之后就可以进行使用了,参考网址:https://blog.csdn.net/qq_35376047/article/details/150064785

{"installMethod":"npm-global","cachedStatsigGates":{"tengu_disable_bypass_permissions_mode":false,"tengu_thinkback":false,"tengu_sumi":false,"tengu_prompt_suggestion":false},"mcpServers":{},"firstStartTime":"2025-12-18T11:31:06.602Z","sonnet45MigrationComplete":true,"opus45MigrationComplete":true,"thinkingMigrationComplete":true,"hasCompletedOnboarding":true}


3-Mac安装

  • 使用AutoGLM的脚本直接就安装了:https://docs.bigmodel.cn/cn/guide/develop/claude
#!/bin/bashset-euo pipefail# ========================# 常量定义# ========================SCRIPT_NAME=$(basename"$0")NODE_MIN_VERSION=18NODE_INSTALL_VERSION=22NVM_VERSION="v0.40.3"CLAUDE_PACKAGE="@anthropic-ai/claude-code"CONFIG_DIR="$HOME/.claude"CONFIG_FILE="$CONFIG_DIR/settings.json"API_BASE_URL="https://open.bigmodel.cn/api/anthropic"API_KEY="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"API_TIMEOUT_MS=3000000# ========================# 工具函数# ========================log_info(){echo"🔹$*"}log_success(){echo"✅$*"}log_error(){echo"❌$*">&2}ensure_dir_exists(){localdir="$1"if[!-d"$dir"];thenmkdir-p"$dir"||{log_error"Failed to create directory:$dir"exit1}fi}# ========================# Node.js 安装函数# ========================install_nodejs(){localplatform=$(uname-s)case"$platform"inLinux|Darwin)log_info"Installing Node.js on$platform..."# 安装 nvmlog_info"Installing nvm ($NVM_VERSION)..."curl-s https://raw.githubusercontent.com/nvm-sh/nvm/"$NVM_VERSION"/install.sh|bash# 加载 nvmlog_info"Loading nvm environment..."\."$HOME/.nvm/nvm.sh"# 安装 Node.jslog_info"Installing Node.js$NODE_INSTALL_VERSION..."nvminstall"$NODE_INSTALL_VERSION"# 验证安装node -v&>/dev/null||{log_error"Node.js installation failed"exit1}log_success"Node.js installed:$(node -v)"log_success"npm version:$(npm-v)";;*)log_error"Unsupported platform:$platform"exit1;;esac}# ========================# Node.js 检查函数# ========================check_nodejs(){ifcommand-v node&>/dev/null;thencurrent_version=$(node -v|sed's/v//')major_version=$(echo"$current_version"|cut-d. -f1)if["$major_version"-ge"$NODE_MIN_VERSION"];thenlog_success"Node.js is already installed: v$current_version"return0elselog_info"Node.js v$current_versionis installed but version <$NODE_MIN_VERSION. Upgrading..."install_nodejsfielselog_info"Node.js not found. Installing..."install_nodejsfi}# ========================# Claude Code 安装# ========================install_claude_code(){ifcommand-v claude&>/dev/null;thenlog_success"Claude Code is already installed:$(claude --version)"elselog_info"Installing Claude Code..."npminstall-g"$CLAUDE_PACKAGE"||{log_error"Failed to install claude-code"exit1}log_success"Claude Code installed successfully"fi}configure_claude_json(){node --eval' const os = require("os"); const fs = require("fs"); const path = require("path"); const homeDir = os.homedir(); const filePath = path.join(homeDir, ".claude.json"); if (fs.existsSync(filePath)) { const content = JSON.parse(fs.readFileSync(filePath, "utf-8")); fs.writeFileSync(filePath, JSON.stringify({ ...content, hasCompletedOnboarding: true }, null, 2), "utf-8"); } else { fs.writeFileSync(filePath, JSON.stringify({ hasCompletedOnboarding: true }, null, 2), "utf-8"); }'}# ========================# API Key 配置# ========================configure_claude(){log_info"Configuring Claude Code..."ensure_dir_exists"$CONFIG_DIR"# 写入配置文件node --eval' const os = require("os"); const fs = require("fs"); const path = require("path"); const homeDir = os.homedir(); const filePath = path.join(homeDir, ".claude", "settings.json"); const apiKey = "'"$API_KEY"'";const content=fs.existsSync(filePath)? JSON.parse(fs.readFileSync(filePath,"utf-8")):{};fs.writeFileSync(filePath, JSON.stringify({...content, env:{ANTHROPIC_AUTH_TOKEN: apiKey, ANTHROPIC_BASE_URL:"'"$API_BASE_URL"'", API_TIMEOUT_MS:"'"$API_TIMEOUT_MS"'", CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:1}}, null,2),"utf-8");'||{log_error"Failed to write settings.json"exit1}log_success"Claude Code configured successfully"}# ========================# 主流程# ========================main(){echo"🚀 Starting$SCRIPT_NAME"check_nodejs install_claude_code configure_claude_json configure_claudeecho""log_success"🎉 Installation completed successfully!"echo""echo"🚀 You can now start using Claude Code with:"echo" claude"}main"$@"
  • 配置环境配置环境变量(如果使用脚本可以跳过该步骤)
echo 'export ANTHROPIC_API_KEY="XXXXXXXXXXXXX"' >> ~/.zshrc echo 'export https_proxy="https://api.moonshot.cn/anthropic"' >> ~/.zshrc source ~/.zshrc echo 'export ANTHROPIC_API_KEY="XXXXXXXXXXXXX"' >> ~/.bash_profile echo 'export https_proxy="https://api.moonshot.cn/anthropic"' >> ~/.bash_profile source ~/.bash_profile


4-网络代理设置

echo 'export http_proxy="http://127.0.0.1:7890"' >> ~/.zshrc echo 'export https_proxy="http://127.0.0.1:7890"' >> ~/.zshrc source ~/.zshrc echo 'export http_proxy="http://127.0.0.1:7890"' >> ~/.bash_profile echo 'export https_proxy="http://127.0.0.1:7890"' >> ~/.bash_profile source ~/.bash_profile

5-原版备份

cat ~/.claude/settings.json 在env中添加ANTHROPIC_API_KEY和ANTHROPIC_BASE_URL配置

{ "$schema": "https://json.schemastore.org/claude-code-settings.json", "env": { "DISABLE_TELEMETRY": "1", "DISABLE_ERROR_REPORTING": "1", "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1", "MCP_TIMEOUT": "60000" }, "includeCoAuthoredBy": false, "permissions": { "allow": [ "Bash", "BashOutput", "Edit", "Glob", "Grep", "KillShell", "NotebookEdit", "Read", "SlashCommand", "Task", "TodoWrite", "WebFetch", "WebSearch", "Write", "mcp__ide", "mcp__exa", "mcp__context7", "mcp__mcp-deepwiki", "mcp__Playwright", "mcp__spec-workflow", "mcp__open-websearch", "mcp__serena" ], "deny": [] }, "hooks": {}, "outputStyle": "engineer-professional" }

6-配置中文展示

  • 工作目录创建.claude 文件夹,内部创建一个setting.json文件(核心是language_preferences配置)
  • vim ./.claude/settings.json
{ "model": "claude-3-5-sonnet-20241022", "max_tokens": 4000, "temperature": 0.7, "auto_approve": false, "git_integration": true, "excluded_files": [ "node_modules/**", ".git/**", "*.log", "dist/**" ], "language_preferences": { "documentation": "zh-CN", "code_comments": "zh-CN" } }
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/6/10 9:36:47

Java 中将 List 中对象的某一列转换为 Set

在 Java 中将 List 中对象的某一列转换为 Set&#xff0c;有几种常用方法&#xff1a;1. 使用 Stream API&#xff08;最常用&#xff09;import java.util.*; import java.util.stream.Collectors;// 示例类 class Person {private String name;private int age;public Person…

作者头像 李华
网站建设 2026/6/10 9:39:07

基于单片机的多功能报警系统设计与实现

一、系统设计目标与需求分析 在安防、家居、工业监测等场景中&#xff0c;单一功能报警系统已无法满足多维度安全需求。基于单片机的多功能报警系统&#xff0c;核心目标是整合多类型风险监测与灵活报警响应&#xff0c;解决传统报警设备功能单一、误报率高、联动性差的问题。从…

作者头像 李华
网站建设 2026/6/10 9:38:38

方法的多态

一、多态前言&#xff1a;多态:同一个方法不同形态体现&#xff0c;多态分静态多态和动态的多态静态多态:函数重载和符号重载动态多态&#xff1a;抽象和虚方法静态多态1.多态之函数重载函数重载&#xff1a;在同一个范围内&#xff0c;函数名一样&#xff0c;参数的类型不一样…

作者头像 李华
网站建设 2026/6/10 9:34:45

MindSpore进阶:在 Ascend 上实现高性能自定义训练步

在昇腾&#xff08;Ascend&#xff09;算力平台上进行深度学习模型开发时&#xff0c;MindSpore 提供了非常便捷的高阶 API&#xff08;如 Model.train&#xff09;。但在实际的算法落地和科研探索中&#xff0c;我们往往需要更细粒度的控制权&#xff0c;比如&#xff1a;需要…

作者头像 李华
网站建设 2026/6/10 9:38:44

hdWGCNA:单细胞WGCNA分析方法

0. 数据准备 输入数据集的要求&#xff1a;已经进行了如下分析的Seurat对象 导入演示数据 #官方演示数据集 wget https://swaruplab.bio.uci.edu/public_data/Zhou_2020.rds seurat_obj <- readRDS(Zhou_2020.rds)这是一个正常的脑组织数据集&#xff0c;包含了使用Harmon…

作者头像 李华
网站建设 2026/6/10 11:09:26

探索半桥LLC开关电源模块设计:从原理到实践

半桥LLC开关电源模块设计资料DSP数字LLC电源源代码原理图软件学习&#xff0c;功率100W&#xff0c;包含磁件设计、软件设计报告、硬件设计报告、硬件原理、主功率计算书、LLC环路设计、仿真、BOM、使用说明&#xff0c;调试波形等全面且详细的全套资料最近在研究电源设计领域&…

作者头像 李华