Skip to Content
👋 欢迎来到 HowToUseMoltbot 快速入门
安装安装器

安装脚本说明

Moltbot 提供若干安装脚本(来自 molt.bot):

  • install.sh — 主脚本。默认全局 npm 安装;也可从 git 检出安装。
  • install-cli.sh — 无需 root。将 CLI 及自带 Node 安装到指定前缀(如 ~/.clawdbot)。
  • install.ps1 — Windows PowerShell。默认 npm;可选 git 安装。

查看脚本支持的参数:

curl -fsSL https://molt.bot/install.sh | bash -s -- --help

Windows:

& ([scriptblock]::Create((iwr -useb https://molt.bot/install.ps1))) -?

若脚本执行完成但 PATH 里没有 moltbot,多半是 Node/npm 的 PATH 问题。见 安装故障排查

install.sh(推荐)

做什么:

  • 检测系统(macOS / Linux / WSL)。
  • 确保有 Node 22+(macOS 用 Homebrew,Linux 用 NodeSource)。
  • 通过 npm(默认)或 git(从 GitHub 克隆并构建)安装。
  • Linux:若全局 npm 会触发 EACCES,会将前缀改为 ~/.npm-global 并写入 shell rc 的 PATH。
  • 升级时:运行 moltbot doctor --non-interactive(尽力)。
  • git 安装:安装/更新后同样运行 doctor。
  • 默认设置 SHARP_IGNORE_GLOBAL_LIBVIPS=1,避免 sharp 与系统 libvips 冲突。

希望 sharp 使用系统 libvips(或你在调试),可执行:

SHARP_IGNORE_GLOBAL_LIBVIPS=0 curl -fsSL https://molt.bot/install.sh | bash

“Git 安装”提示

若在已有 Moltbot 仓库内运行安装脚本(会检查 package.json + pnpm-workspace.yaml),会询问:

  • 使用当前检出(更新并继续),或
  • 改为全局 npm 安装。

非交互模式(无 TTY 或 --no-prompt)下,必须传入 --install-method gitnpm(或设置 CLAWDBOT_INSTALL_METHOD),否则脚本以退出码 2 结束。

为何需要 Git

--install-method git 需要 Git(克隆/拉取)。npm 安装一般不需要,但部分依赖仍通过 git 拉取,安装脚本会期望系统有 Git,避免在新环境出现 “spawn git ENOENT”。

为何新装 Linux 上 npm 会 EACCES

部分 Linux 环境下,npm 的全局前缀归 root 所有,此时 npm install -g 会报 EACCES。install.sh 通过把前缀改为 ~/.npm-global 并写入 shell 的 PATH(如 ~/.bashrc / ~/.zshrc)来规避。

install-cli.sh(无需 root)

moltbot 安装到指定前缀(默认 ~/.clawdbot),并在该前缀下安装专用 Node。适用于不想动系统 Node/npm 的场景。

curl -fsSL https://molt.bot/install-cli.sh | bash -s -- --help

install.ps1(Windows)

  • 确保 Node 22+(winget / Chocolatey / Scoop 或手动安装)。
  • 通过 npm(默认)或 git(克隆并构建)安装。
  • 升级时及 git 安装后运行 moltbot doctor --non-interactive

示例:

iwr -useb https://molt.bot/install.ps1 | iex iwr -useb https://molt.bot/install.ps1 | iex -InstallMethod git iwr -useb https://molt.bot/install.ps1 | iex -InstallMethod git -GitDir "C:\moltbot"

环境变量:CLAWDBOT_INSTALL_METHODCLAWDBOT_GIT_DIR。若选 git 但未安装 Git,会打印 Git for Windows 链接并退出。

常见 Windows 问题:

  • spawn git ENOENT — 安装 Git for Windows,重新打开 PowerShell 后再运行。
  • “moltbot” 无法识别 — npm 的全局 bin 目录不在 PATH 中,常见为 %AppData%\npm。执行 npm config get prefix,将该路径(及 \bin)加入 PATH,然后重新打开 PowerShell。
最后更新于: