环境准备
本次操作基于原生 Windows 11 环境(未启用 WSL2),Node.js 版本为 24.12.0 (LTS),npm 版本为 11.7.0。如果你也在这个环境下遇到了安装卡住或报错的情况,可以参考下面的排查步骤。
安装命令
OpenClaw 支持两种安装方式,根据需求选择即可:
通用稳定版
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。npm 在拉取源码时需要调用 Git 命令,找不到自然就会失败。
解决起来很简单:
- 去 Git 官网下载 Windows 安装包。
- 运行安装程序,一路默认下一步就行。
- 关键点:在安装过程中,务必勾选
Git from the command line and also from 3rd-party software选项。这一步会自动把 Git 加入环境变量,省得你手动配置 PATH。 - 安装完成后,关闭所有终端窗口重新打开一个,输入
git --version确认一下是否生效。
缺少 GitHub 权限
装好 Git 后如果还是报错,比如出现 [email protected]: Permission denied (publickey) / code 128,那通常是 SSH 密钥的问题。咱们不需要配置复杂的 SSH Key,直接强制 Git 使用 HTTPS 协议就能绕过验证。
具体操作如下:
- 用记事本打开用户目录下的
.gitconfig文件。可以在终端运行notepad %USERPROFILE%\.gitconfig快速定位并编辑。 - 清空里面的内容,粘贴以下配置块。这段配置会把 GitHub 的所有访问请求重定向到镜像源,避免直连被墙或权限校验失败。
[url "https://gitclone.com/github.com/"]
insteadOf = [email protected]:
insteadOf = ssh://[email protected]/
insteadOf = https://github.com/
- 保存文件后,回到终端清理一下 npm 缓存,然后再次尝试安装。
npm cache clean --force
npm install -g openclaw@latest
如果在安装过程中遇到拿不准的步骤,可以先跳过,后续通过 openclaw onboard 命令回来修改配置也不迟。

