这个仓库提供一个面向中国大陆网络环境优化的 OpenClaw Windows 安装脚本。
- 默认使用国内 npm 镜像:
https://registry.npmmirror.com - GitHub 下载与克隆支持“镜像优先、源站回退”
- 全局安装 OpenClaw 时采用
pnpm优先,失败自动回退到npm - 安装完成后自动尝试应用 Windows ESM 热补丁(幂等)
- 尽量保持与官方安装脚本一致的流程,减少额外行为
install-openclaw-cn.ps1:主安装脚本patch-openclaw-windows-esm.ps1:Windows ESM 热补丁脚本(可单独执行)repair-openclaw-windows.ps1:一键修复(可选npm全局重装 + 打 ESM 补丁;默认结束后尝试openclaw gateway restart)
这个补丁专门用于缓解 OpenClaw 在原生 Windows 下常见的:
ERR_UNSUPPORTED_ESM_URL_SCHEME(Received protocol 'c:')问题。
- 定位全局安装目录中的
openclaw/node_modules/jiti/lib/jiti.mjs - 将
nativeImport的 Windows 绝对路径导入逻辑改为file://URL 导入 - 幂等执行:如果已打过补丁,会自动跳过,不会重复改坏
- 当你执行
npm/pnpm升级或重装openclaw后,node_modules可能被重写,补丁可能失效。 - 本仓库的
install-openclaw-cn.ps1已内置“安装后自动尝试打补丁”的流程。
powershell -ExecutionPolicy Bypass -File .\patch-openclaw-windows-esm.ps1默认:只打 ESM 补丁,并尝试 openclaw gateway restart(可用 -NoGatewayRestart 跳过)。
powershell -ExecutionPolicy Bypass -File .\repair-openclaw-windows.ps1若升级/重装后希望先拉干净包再打补丁:
powershell -ExecutionPolicy Bypass -File .\repair-openclaw-windows.ps1 -Reinstall -Tag latest若国内镜像拉到的包出现 dist 内语法错误(例如乱码、未闭合字符串),可对 -Reinstall 指定官方源:
powershell -ExecutionPolicy Bypass -File .\repair-openclaw-windows.ps1 -Reinstall -Tag 2026.4.5 -Registry https://registry.npmjs.org本地执行安装(跳过首次向导):
powershell -ExecutionPolicy Bypass -File .\install-openclaw-cn.ps1 -NoOnboard仅检查流程(不实际安装):
powershell -ExecutionPolicy Bypass -File .\install-openclaw-cn.ps1 -DryRunOPENCLAW_NPM_REGISTRY:自定义 npm registry
默认值:https://registry.npmmirror.comOPENCLAW_GITHUB_MIRROR:自定义 GitHub 镜像前缀
默认值:https://gh-proxy.com/
示例:
$env:OPENCLAW_NPM_REGISTRY="https://registry.npmmirror.com"
$env:OPENCLAW_GITHUB_MIRROR="https://gh-proxy.com/"
powershell -ExecutionPolicy Bypass -File .\install-openclaw-cn.ps1- 适用于原生 Windows PowerShell 环境。
- 如果 OpenClaw 官方脚本后续有更新,建议基于最新官方版本重新同步本仓库改动。
这是 OpenClaw 在原生 Windows 上的已知问题之一,典型报错是:
Only URLs with a scheme in: file, data, and node ... Received protocol 'c:'
根因是某些动态导入路径在 Windows 下没有被正确转换为 file:// URL。
截至目前,官方最新正式发布仍是 v2026.4.5:
https://github.com/openclaw/openclaw/releases/tag/v2026.4.5
同时,相关问题仍有 OPEN 的 issue(说明在最新正式版场景下仍有人持续复现):
- #61899(OPEN)
openclaw/openclaw#61899
另有同类问题已被关闭并标记修复(说明官方在 main 分支已经做过修复):
- #61795(CLOSED)
openclaw/openclaw#61795 - #61810(CLOSED)
openclaw/openclaw#61810 - #61911(CLOSED)
openclaw/openclaw#61911
有,当前可追踪到:
- #62444(OPEN):
fix(windows): resolve ERR_UNSUPPORTED_ESM_URL_SCHEME on native Windows
openclaw/openclaw#62444
另外,下面这些修复已进入主分支,但是否包含在你安装到的 release 里,取决于后续正式发版:
- #62286(MERGED)
openclaw/openclaw#62286 - #61832(CLOSED,说明同类修复已由维护者以其他方式落地)
openclaw/openclaw#61832
不能保证 100% 解决。
本仓库脚本除了优化安装与下载链路(国内镜像、pnpm 优先、回退策略),也会在安装后自动对本地 jiti.mjs 执行热补丁;但由于上游变更、安装形态差异或未来文件结构变化,仍无法保证所有环境都一次修复。
如果你遇到该报错,建议关注上面的 issue/PR 进展,或优先使用 WSL2 路径。
This repository contains a China-network-friendly Windows installer for OpenClaw:
- Default npm mirror:
https://registry.npmmirror.com - GitHub mirror-first with origin fallback
pnpm-first global install withnpmfallback- Keeps upstream installer flow as close as possible