安装程序内部
OpenClaw 提供两个安装脚本(从 openclaw.ai 提供):
https://openclaw.bot/install.sh— "推荐"安装程序(默认通过全局 npm 安装;也可以从 GitHub 检出安装)https://openclaw.bot/install-cli.sh— 非 root 友好的 CLI 安装程序(安装到带有自己 Node 的前缀中)https://openclaw.ai/install.ps1— Windows PowerShell 安装程序(默认 npm;可选 git 安装)
查看当前标志/行为:
curl -fsSL https://openclaw.bot/install.sh | bash -s -- --helpWindows (PowerShell) 帮助:
& ([scriptblock]::Create((iwr -useb https://openclaw.ai/install.ps1))) -?如果安装程序完成但在新终端中找不到 openclaw,通常是 Node/npm PATH 问题。参见:安装
install.sh(推荐)
它做什么(高级):
- 检测操作系统(macOS / Linux / WSL)。
- 确保 Node.js 22+(macOS 通过 Homebrew;Linux 通过 NodeSource)。
- 选择安装方法:
npm(默认):npm install -g openclaw@latestgit:克隆/构建源码检出并安装包装器脚本
- 在 Linux 上:通过在需要时将 npm 的前缀切换到
~/.npm-global来避免全局 npm 权限错误。 - 如果升级现有安装:运行
openclaw doctor --non-interactive(尽力而为)。 - 对于 git 安装:安装/更新后运行
openclaw doctor --non-interactive(尽力而为)。 - 通过默认
SHARP_IGNORE_GLOBAL_LIBVIPS=1来缓解sharp原生安装问题(避免根据系统 libvips 构建)。
如果你确实希望 sharp 链接到全局安装的 libvips(或正在调试),设置:
SHARP_IGNORE_GLOBAL_LIBVIPS=0 curl -fsSL https://openclaw.bot/install.sh | bash可发现性 / "git install" 提示
如果你在已经处于 OpenClaw 源码检出中时运行安装程序(通过 package.json + pnpm-workspace.yaml 检测),它会提示:
- 更新并使用此检出(
git) - 或迁移到全局 npm 安装(
npm)
在非交互式上下文(无 TTY / --no-prompt)中,你必须传递 --install-method git|npm(或设置 OPENCLAW_INSTALL_METHOD),否则脚本会以代码 2 退出。
为什么需要 Git
Git 需要用于 --install-method git 路径(克隆 / 拉取)。
对于 npm 安装,Git 通常不需要,但某些环境最终仍然需要它(例如,当包或依赖通过 git URL 获取时)。安装程序目前确保存在 Git 以避免在全新发行版上出现 spawn git ENOENT 意外。
为什么 npm 在全新的 Linux 上遇到 EACCES
在某些 Linux 设置上(特别是在通过系统包管理器或 NodeSource 安装 Node 之后),npm 的全局前缀指向一个 root 拥有的位置。然后 npm install -g ... 会因 EACCES / mkdir 权限错误而失败。
install.sh 通过将前缀切换到以下内容来缓解:
~/.npm-global(并在存在时将其添加到~/.bashrc/~/.zshrc中的PATH)
install-cli.sh(非 root CLI 安装程序)
此脚本将 openclaw 安装到前缀中(默认:~/.openclaw),并且还在该前缀下安装专用的 Node 运行时,因此它可以在你不想触摸系统 Node/npm 的机器上工作。
帮助:
curl -fsSL https://openclaw.bot/install-cli.sh | bash -s -- --helpinstall.ps1(Windows PowerShell)
它做什么(高级):
- 确保 Node.js 22+(winget/Chocolatey/Scoop 或手动)。
- 选择安装方法:
npm(默认):npm install -g openclaw@latestgit:克隆/构建源码检出并安装包装器脚本
- 在升级和 git 安装上运行
openclaw doctor --non-interactive(尽力而为)。
示例:
iwr -useb https://openclaw.ai/install.ps1 | iexiwr -useb https://openclaw.ai/install.ps1 | iex -InstallMethod gitiwr -useb https://openclaw.ai/install.ps1 | iex -InstallMethod git -GitDir "C:\\openclaw"环境变量:
OPENCLAW_INSTALL_METHOD=git|npmOPENCLAW_GIT_DIR=...
Git 要求:
如果你选择 -InstallMethod git 并且缺少 Git,安装程序会打印 Git for Windows 链接(https://git-scm.com/download/win)然后退出。
常见 Windows 问题:
- npm error spawn git / ENOENT:安装 Git for Windows 并重新打开 PowerShell,然后重新运行安装程序。
- "openclaw" 无法识别:你的 npm 全局 bin 文件夹不在 PATH 上。大多数系统使用
%AppData%\npm。你也可以运行npm config get prefix并将\bin添加到 PATH,然后重新打开 PowerShell。