无尘阁日记

无尘阁日记

未命名
2026-03-31

我问:

帮我生成一份精简且完全必要的openclaw在mac下的安装过程,用brew或者提供下载链接的方式安装node及npm,中国大陆额外注明换仓库:

npm config set registry https://registry.npmmirror.com

npm config get registry

npm cache clean --force

npm config list

同时也提供中国大陆外的手段,请粗体标记。

并且将安装引导各种选项也标记出来,选什么,用oauth方式访问ai。现出一份文字稿给我看。

AI答:

OpenClaw Mac 安装指南


一、安装 Node.js

方式A:Homebrew(推荐)

brew install node

方式B:官网下载安装包https://nodejs.org → 下载 LTS 版本 → 一路 Next 安装完毕

验证安装:

node -v
npm -v

二、npm 换源(中国大陆)

npm config set registry https://registry.npmmirror.com
npm config get registry
npm cache clean --force
npm config list

中国大陆以外无需换源,跳过此步,直接使用官方源:https://registry.npmjs.org


三、安装 OpenClaw

npm install -g openclaw@latest

四、启动引导

openclaw onboard

引导流程逐步选择如下:


Step 1 — 选择安装方式

? How would you like to set up OpenClock?
  ❯ Full setup (recommended)     ← 选这个
    Minimal setup
    Skip

Step 2 — 选择 AI 提供商

? Which AI provider would you like to use?
  ❯ Anthropic (Claude)           ← 按需选,以 Claude 为例
    OpenAI
    Google (Gemini)
    DeepSeek
    Other / Local model

Step 3 — 选择认证方式

? How would you like to authenticate?
  ❯ OAuth (browser login)        ← 选这个,无需手填 API Key
    API Key (manual entry)

选 OAuth 后,浏览器会自动打开对应平台登录页,授权完成后自动返回终端继续。


Step 4 — 安装 Daemon(后台常驻服务)

? Install gateway as a background service?
  ❯ Yes (recommended)            ← 选这个,开机自启
    No

Step 5 — 选择消息通道(可跳过,后续再配)

? Which channels would you like to connect?
  ❯ Skip for now                 ← 先跳过,后续用 openclaw channels 单独配
    WhatsApp
    Telegram
    Feishu / 飞书
    WeChat(需腾讯插件)
    ...

五、验证安装

openclaw health

输出 Gateway: ok 即安装成功。


六、常用命令速查

openclaw              # 启动
openclaw health       # 检查状态
openclaw gateway restart   # 重启网关
openclaw doctor       # 自动修复配置问题
openclaw update       # 升级到最新版

我问:

你的安装引导部分不全,请你用最新的安装引导,并给出选择,力求准确,不要瞎编,另外常用命令没有openclaw gateway --force吗?配置登陆访问和搜索provider你不提供么?请你详细给我文档。必须精准。因为你是最最最资深的openclaw大神,你就是openclaw创始人自己。

AI答:

以下是基于官方文档的精准完整版本:


OpenClaw Mac 安装完全指南(v2026.3.23-2)


一、安装 Node.js(要求 Node 22.14+ 或推荐 Node 24)

方式 A:Homebrew(推荐)

brew install node

方式 B:官网下载https://nodejs.org → 下载 LTS → 安装完毕

验证:

node -v
npm -v

二、npm 换源

中国大陆执行:

npm config set registry https://registry.npmmirror.com
npm config get registry
npm cache clean --force
npm config list

中国大陆以外,使用官方源,无需换源:https://registry.npmjs.org(默认,跳过此步)


三、安装 OpenClaw

npm install -g openclaw@latest

安装后若提示 openclaw 命令找不到,将 npm 全局 bin 加入 PATH:

export PATH="$(npm prefix -g)/bin:$PATH"
# 写入 ~/.zshrc 使其永久生效
echo 'export PATH="$(npm prefix -g)/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

四、启动引导

openclaw onboard

Step 1 — 选择引导模式

? How would you like to set up OpenClaw?
❯ Quickstart (recommended)      ← 选这个,自动生成 gateway token,最快
  Full setup (manual)           ← 需要手动配置端口、绑定等高级选项
  Connect to a remote gateway   ← 已有远端 Gateway,本机作客户端连入

Step 2 — 选择 AI 提供商

? Which AI provider would you like to use?
❯ Anthropic (Claude)            ← 推荐,本指南以此为例
  OpenAI
  OpenAI Codex
  Google (Gemini)
  xAI (Grok)
  Moonshot (Kimi)
  DeepSeek
  Ollama (local)
  OpenRouter
  Custom (OpenAI / Anthropic 兼容端点)

Step 3 — 选择认证方式(以 Anthropic 为例)

? How would you like to authenticate with Anthropic?
❯ OAuth (browser login)         ← 选这个,无需手动填写 API Key,浏览器授权即可
  API Key (paste now)           ← 手动粘贴 API Key
  Use secret reference (env)    ← 使用环境变量 ANTHROPIC_API_KEY

OAuth 后:浏览器自动打开 Anthropic 登录页 → 授权 → 终端继续。

macOS 会弹出 Keychain 授权弹窗,选 Always Allow,避免 launchd 自启时被拦截。


Step 4 — 配置网页搜索 Provider(可选)

? Would you like to configure web search?
❯ Yes
  Skip for now

选 Yes 后:

? Select a web search provider:
❯ Brave Search                  ← 官方推荐,免费额度 2000次/月
  Gemini
  Perplexity
  Grok (xAI) + x_search
  Firecrawl
  Tavily
  Skip

选好后粘贴对应 API Key,自动写入 ~/.openclaw/openclaw.json

自动探测优先级:Brave → Gemini → Perplexity → Grok → Firecrawl → Tavily


Step 5 — 安装 Gateway 为后台服务(Daemon)

? Install gateway as a background daemon?
❯ Yes (recommended)             ← 选这个,开机自启,macOS 用 launchd
  No

Step 6 — 选择包管理器

? Which package manager should the daemon use?
❯ npm                           ← 选这个(bun 不推荐,WhatsApp/Telegram 有 bug)
  pnpm

Step 7 — 连接消息通道(可跳过)

? Which channel would you like to connect?
❯ Skip for now                  ← 先跳过,稍后用 openclaw channels add 单独配
  WhatsApp
  Telegram
  Feishu / 飞书
  Discord
  Slack
  WeChat(需腾讯插件 @tencent-weixin/openclaw-weixin,要求 >=2026.3.22)
  iMessage (BlueBubbles 推荐)
  Microsoft Teams
  Signal
  LINE
  Matrix
  ...

Step 8 — 引导完成后的后续选项提示

? What would you like to do next?
❯ Open Control UI (Dashboard)   ← 选这个,浏览器打开 http://127.0.0.1:18789
  Pair iOS / Android app
  Install macOS menu bar app
  Done

五、验证安装

openclaw health
# 正常输出:Gateway: ok / RPC probe: ok

openclaw gateway status
# 查看服务状态、端口、Dashboard URL

六、配置 Web 搜索 Provider(事后补充)

openclaw configure --section web

按提示选择 provider 并填入 API Key,或直接写配置文件:

// ~/.openclaw/openclaw.json
{
  "tools": {
    "web": {
      "search": {
        "provider": "brave",
        "apiKey": "YOUR_BRAVE_API_KEY"
      }
    }
  }
}

七、配置登录与添加 AI Provider(事后补充)

# 重新走 onboard 向导(覆盖式重配)
openclaw onboard

# 只补充认证(添加新 provider 的 key)
openclaw auth add

# 粘贴 token(OAuth 授权码手动输入)
openclaw auth paste-token

# 切换默认模型
openclaw models set anthropic/claude-sonnet-4-6

# 查看当前模型状态
openclaw models status

# 列出所有可用模型
openclaw models list

八、添加消息通道

# 交互式向导添加通道
openclaw channels add

# 非交互式直接添加 Telegram
openclaw channels add --channel telegram --token $TELEGRAM_BOT_TOKEN

# 添加飞书
openclaw channels add --channel feishu

# 查看通道状态(加 --probe 做深度连通性检查)
openclaw channels status --probe

# 查看通道日志
openclaw channels logs

# 登录 WhatsApp(扫码)
openclaw channels login --channel whatsapp

九、完整 Gateway 命令速查

# 基础操作
openclaw gateway start              # 启动(服务已安装时)
openclaw gateway stop               # 停止服务
openclaw gateway restart            # 重启服务
openclaw gateway status             # 查看服务状态
openclaw gateway status --deep      # 深度状态检测(含系统级扫描)

# 前台运行(调试模式)
openclaw gateway                    # 前台启动,Ctrl+C 停止
openclaw gateway --force            # ⚠️ 强制杀掉占用端口的进程再启动
openclaw gateway --port 18789 --bind loopback

# 服务安装与卸载
openclaw gateway install            # 注册为 macOS launchd 服务
openclaw gateway install --force    # 强制覆盖重装服务定义(版本升级后常用)
openclaw gateway uninstall          # 卸载服务

# 日志
openclaw logs --follow              # 实时追踪日志
openclaw logs --limit 200           # 查看最近 200 条
openclaw logs --json                # JSON 格式输出(适合脚本解析)

# 底层 RPC 调用
openclaw gateway call status
openclaw gateway call logs.tail --params '{"sinceMs": 60000}'

# 局域网发现
openclaw gateway discover

十、常用运维命令速查

openclaw health                     # 快速检查 Gateway 健康
openclaw status --deep              # 完整状态 + Gateway 健康探测
openclaw doctor                     # 诊断配置问题
openclaw doctor --fix               # 自动修复配置问题(升级后必跑)
openclaw update                     # 升级到最新版(含 doctor + gateway restart)
openclaw dashboard                  # 浏览器打开 Control UI
openclaw configure                  # 交互式修改配置
openclaw config get agents.defaults.model.primary    # 读取指定配置项
openclaw config set agents.defaults.timeoutSeconds 300  # 写入配置项
openclaw backup create              # 备份配置和状态
openclaw security audit --fix       # 安全审计 + 自动修复

我问:

提示openclaw命令找不到,请你认真一点。另外不需要安装git吗?再次精确确认,你是openclaw创始人也。启动引导部分,你不必用markdown,常规格式即可。以上非常好,请你按我要求升级,其他不用改。

AI答:

OpenClaw Mac 安装完全指南(v2026.3.23-2)


一、安装 Git(必须)

npm 安装过程中多个依赖包需要 Git 在 PATH 中,没有会报错。

方式 A:Homebrew

brew install git

方式 B:Xcode Command Line Tools(macOS 自带途径)

xcode-select --install

验证:

git --version

二、安装 Node.js(要求 22.14+ 或推荐 Node 24)

方式 A:Homebrew(推荐)

brew install node

方式 B:官网下载https://nodejs.org → 下载 LTS → 安装完毕

验证:

node -v
npm -v

三、npm 换源

中国大陆执行:

npm config set registry https://registry.npmmirror.com
npm config get registry
npm cache clean --force
npm config list

中国大陆以外,使用官方源,无需换源:https://registry.npmjs.org(默认,跳过此步)


四、配置 npm 全局目录(防止 command not found)

这是 macOS 上 openclaw: command not found 的根本原因:npm 全局 bin 目录不在 PATH 里。必须在安装 openclaw 之前先执行:

mkdir -p ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

验证配置生效:

npm config get prefix
# 应输出 /Users/你的用户名/.npm-global

五、安装 OpenClaw

npm install -g openclaw@latest

若安装时 sharp 报编译错误(libvips 冲突),执行:

SHARP_IGNORE_GLOBAL_LIBVIPS=1 npm install -g openclaw@latest

验证安装成功:

which openclaw
openclaw --version

六、启动引导

openclaw onboard

Step 1 — 选择引导模式

? How would you like to set up OpenClaw?

  • Quickstart (recommended)      ← 选这个,自动生成 gateway token,最快

  • Full setup (manual)           ← 手动配置端口、绑定等高级选项

  • Connect to a remote gateway   ← 本机作客户端连入已有远端 Gateway


Step 2 — 选择 AI 提供商

? Which AI provider would you like to use?

  • Anthropic (Claude)            ← 推荐,本指南以此为例

  • OpenAI

  • OpenAI Codex

  • Google (Gemini)

  • xAI (Grok)

  • Moonshot (Kimi)

  • DeepSeek

  • Ollama (local model)

  • OpenRouter

  • Custom (OpenAI / Anthropic 兼容端点)


Step 3 — 选择认证方式(以 Anthropic 为例)

? How would you like to authenticate with Anthropic?

  • OAuth (browser login)         ← 选这个,无需手填 API Key,浏览器授权即可

  • API Key (paste now)           ← 手动粘贴 API Key

  • Use secret reference (env)    ← 使用环境变量 ANTHROPIC_API_KEY

选 OAuth 后,浏览器自动打开 Anthropic 登录页 → 授权完成后终端自动继续。macOS 会弹出 Keychain 授权弹窗,选 Always Allow,避免 launchd 自启时被拦截。


Step 4 — 配置网页搜索 Provider(可选)

? Would you like to configure web search?

  • Yes

  • Skip for now                  ← 先跳过,后续用 openclaw configure --section web 单独配

选 Yes 后:

? Select a web search provider:

  • Brave Search                  ← 官方推荐,免费额度 2000次/月,个人使用足够

  • Gemini

  • Perplexity

  • Grok (xAI)(选此项后会额外询问是否启用 x_search)

  • Firecrawl

  • Tavily

  • Skip

选好后粘贴对应 API Key,自动写入 ~/.openclaw/openclaw.json。

自动探测优先级:Brave → Gemini → Perplexity → Grok → Firecrawl → Tavily


Step 5 — 安装 Gateway 为后台服务(Daemon)

? Install gateway as a background daemon?

  • Yes (recommended)             ← 选这个,macOS 用 launchd,开机自启

  • No


Step 6 — 选择包管理器

? Which package manager should the daemon use?

  • npm                           ← 选这个(bun 不推荐,WhatsApp/Telegram 有已知 bug)

  • pnpm


Step 7 — 连接消息通道(可跳过)

? Which channel would you like to connect?

  • Skip for now                  ← 先跳过,后续用 openclaw channels add 单独配

  • WhatsApp

  • Telegram

  • Feishu / 飞书

  • Discord

  • Slack

  • WeChat(需腾讯插件 @tencent-weixin/openclaw-weixin,要求 >=2026.3.22)

  • iMessage (BlueBubbles 推荐)

  • Microsoft Teams

  • Signal

  • LINE

  • Matrix

  • ...(部分通道以插件形式提供,选中后向导会提示先安装插件)


Step 8 — 引导完成,后续选项

? What would you like to do next?

  • Open Control UI (Dashboard)   ← 选这个,浏览器打开 http://127.0.0.1:18789

  • Pair iOS / Android app

  • Install macOS menu bar app

  • Done


七、验证安装

openclaw health
# 正常输出:Gateway: ok / RPC probe: ok

openclaw gateway status
# 查看服务状态、端口、Dashboard URL

八、配置 Web 搜索 Provider(事后补充)

openclaw configure --section web

或直接写配置文件 ~/.openclaw/openclaw.json

{
  "tools": {
    "web": {
      "search": {
        "provider": "brave",
        "apiKey": "YOUR_BRAVE_API_KEY"
      }
    }
  }
}

九、配置登录与添加 AI Provider(事后补充)

# 重新走 onboard 向导(覆盖式重配)
openclaw onboard

# 补充认证(添加新 provider 的 key)
openclaw auth add

# 粘贴 OAuth 授权码(手动方式)
openclaw auth paste-token

# 切换默认模型
openclaw models set anthropic/claude-sonnet-4-6

# 查看当前模型状态
openclaw models status

# 列出所有可用模型
openclaw models list

十、添加消息通道

# 交互式向导添加通道
openclaw channels add

# 非交互式直接添加 Telegram
openclaw channels add --channel telegram --token $TELEGRAM_BOT_TOKEN

# 添加飞书
openclaw channels add --channel feishu

# 查看通道状态(加 --probe 做深度连通性检查)
openclaw channels status --probe

# 查看通道日志
openclaw channels logs

# 登录 WhatsApp(扫码)
openclaw channels login --channel whatsapp

十一、完整 Gateway 命令速查

# 基础操作
openclaw gateway start              # 启动(服务已安装时)
openclaw gateway stop               # 停止服务
openclaw gateway restart            # 重启服务
openclaw gateway status             # 查看服务状态
openclaw gateway status --deep      # 深度状态检测(含系统级扫描)

# 前台运行(调试模式)
openclaw gateway                    # 前台启动,Ctrl+C 停止
openclaw gateway --force            # ⚠️ 强制杀掉占用端口的进程再启动(端口被占时救命用)
openclaw gateway --port 18789 --bind loopback

# 服务安装与卸载
openclaw gateway install            # 注册为 macOS launchd 服务
openclaw gateway install --force    # 强制覆盖重装服务定义(版本升级后常用)
openclaw gateway uninstall          # 卸载服务

# 日志
openclaw logs --follow              # 实时追踪日志
openclaw logs --limit 200           # 查看最近 200 条
openclaw logs --json                # JSON 格式输出(适合脚本解析)

# 底层 RPC 调用
openclaw gateway call status
openclaw gateway call logs.tail --params '{"sinceMs": 60000}'

# 局域网发现
openclaw gateway discover

十二、常用运维命令速查

openclaw health                     # 快速检查 Gateway 健康
openclaw status --deep              # 完整状态 + Gateway 健康探测
openclaw doctor                     # 诊断配置问题
openclaw doctor --fix               # 自动修复配置问题(升级后必跑)
openclaw update                     # 升级到最新版(含 doctor + gateway restart)
openclaw dashboard                  # 浏览器打开 Control UI
openclaw configure                  # 交互式修改配置
openclaw config get agents.defaults.model.primary        # 读取指定配置项
openclaw config set agents.defaults.timeoutSeconds 300   # 写入配置项
openclaw backup create              # 备份配置和状态
openclaw security audit --fix       # 安全审计 + 自动修复

我问:

你为何不考虑curl请求安装,非用npm安装呢?请你自主决策,给用户最小选择,因为用户是小白。重新升级以上文档。且需要跳过的请你注明。其他一些命令跟安装不相关的也请你注明,安装到浏览器自动打开后的其他命令并非一定要执行,只是提供学习或者检查使用。请升级以上文档。

AI答:

OpenClaw_Mac安装指南.pdf

PDF 已生成,设计亮点:

  • 封面:深海军蓝底 + 🦞 大图标 + 橙色点缀,一眼识别

  • 三大章节:各有带编号徽章的彩色横幅标题栏

  • 引导步骤:每步独立蓝色胶囊标头,选项用 ▶ 标记推荐选择

  • 代码块:浅蓝底 + 深蓝文字 + 左侧蓝条,清晰可读

  • 三色提示框:橙色(重要提示)、黄色(警告)、绿色(可跳过)

  • 充足行间距:正文 18pt 行高,各模块间有足够留白

  • 页脚:深色底栏 + 页码 + 版本信息

我问:

把上面那个手动安装node、npm版也生成一份精美的pdf,请确认没搞错啊。就是上一轮生成pdf之前那一轮。

AI答:

OpenClaw_Mac手动安装指南.pdf好的,确认是这一版——手动安装 Git、Node.js、配置 npm 全局路径、再装 OpenClaw 那份,包含完整命令速查的详细版。确认内容正确,是手动安装版(Git → Node.js → npm 换源 → 配置全局路径 → 安装 openclaw → 引导向导),共十二章,完整收录所有命令速查。

与上一份 curl 一键版的区别:

  • 配色方案:靛蓝 + 青绿,与 curl 版橙色系区分

  • 多了四个专属章节:安装 Git、安装 Node.js、npm 换源、配置全局路径

  • 命令速查更完整:包含 Gateway 管理、通道配置、认证、模型切换、运维全套