环境说明
本文基于原生 Windows 11(未安装 WSL2)环境,Node.js 版本为 24.12.0 (LTS),npm 版本 11.7.0。
安装命令
通用 npm 安装命令如下,用于获取最新稳定版:
npm install -g openclaw@latest
若需安装测试版(beta),可使用官方脚本:
curl -fsSL https://openclaw.ai/install.cmd -o install.cmd && install.cmd --tag beta && del install.cmd
缺少依赖工具
如果执行安装时出现 npm error code ENOENT / syscall spawn git 或提示找不到 Git 文件,通常是因为系统未安装 Git 工具。npm 在拉取源码时需要调用 Git,缺少它会导致命令执行失败。
解决方法很简单:
- 访问 Git 官网下载 Windows 安装包。
- 运行安装程序,全程保持默认设置即可。
- 关键步骤:安装过程中务必勾选
Git from the command line and also from 3rd-party software,这样会自动配置环境变量,无需手动操作。 - 关闭所有终端窗口,重新打开一个新的终端,输入
git --version验证是否生效。
缺少 GitHub 权限
安装完 Git 后,如果遇到 [email protected]: Permission denied (publickey) / code 128 错误,说明 Git 默认使用 SSH 协议访问 GitHub,但本地未配置密钥。此时我们可以强制 Git 使用 HTTPS 协议,暂时绕过密钥验证。
注意:直接在 PowerShell 中执行 git config 可能会因为解析 Bug 导致相同域名的配置被覆盖,仅最后一条规则生效,SSH 协议的替换规则可能丢失。建议直接编辑配置文件。
- 在终端输入以下路径并按回车,用记事本打开该文件:
C:\Users\你的用户名\.gitconfig - 删除文件中所有内容,粘贴以下配置以强制使用镜像源:
[url "https://gitclone.com/github.com/"] insteadOf = [email protected]: [url "https://gitclone.com/github.com/"] insteadOf = ssh://[email protected]/ [url "https://gitclone.com/github.com/"] insteadOf = https://github.com/ - 保存文件后,继续执行清理缓存和安装命令:
npm cache clean --force npm install -g openclaw@latest
如果在安装过程中遇到拿不准的步骤,可以先跳过,后续通过 openclaw onboard 命令回来修改配置。

