Windows 11 下如何安装 OpenClaw

OpenClaw 是一个开源的个人 AI 助手运行时,可以在你自己的电脑上运行一个「网关(Gateway)」,并通过 Telegram、Discord、微信、WhatsApp 等多种渠道与你的 AI 助手对话。本教程将手把手带你在一台 Windows 11 电脑上完成从零安装:先安装 Node.js 和 Git 这两个前置依赖,再安装 OpenClaw,最后完成初始化配置。

一、安装 Node.js

OpenClaw 基于 Node.js 运行,需要 Node 24.16+ 或 26.1+(推荐使用 Node 26 或最新的 LTS 版本)。Node 22、23、25 不受支持。

方法一(推荐):用 winget 安装

winget install OpenJS.NodeJS.LTS

方法二:从官网下载安装包

打开 https://nodejs.org/,下载 Windows 安装包(.msi),一路点击「Next」完成安装。以下为安装过程中的关键界面:

Node.js 安装向导第 1 步
Node.js 安装向导第 2 步
Node.js 安装向导第 3 步



安装完成后,Node.js 安装向导会提示安装完成:

Node.js 安装完成

安装完成后,打开一个新的终端窗口,输入以下命令验证:

node -v
npm -v

二、安装 Git

Git 用于克隆源码、管理版本以及部分插件的安装,建议一并装好。

方法一(推荐):用 winget 安装

winget install Git.Git

方法二:从官网下载安装包

打开 https://git-scm.com/,下载 Windows 版安装包,一路点击「Next」完成安装。安装向导界面如下:

Git 安装向导
安装过程如果遇到git权限问题“git@github.com: Permission denied (publickey)”,需要执行以下命令,强制修改ssh为https。
git config --global url."https://github.com/".insteadOf ssh://git@github.com/

三、验证环境

安装完 Node.js 和 Git 后,在终端中依次执行以下命令,确认版本号正常输出:

node -v
npm -v
git --version
node -v 版本检测
npm -v 版本检测
git --version 版本检测
版本检测汇总

四、安装前的准备

4.1 允许 PowerShell 执行远程脚本

OpenClaw 的官方安装脚本需要从远程下载并在 PowerShell 中执行,而 Windows 默认会阻止运行远程脚本。请先以管理员身份打开 PowerShell,执行以下命令将执行策略设为 RemoteSigned:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

4.2 网络问题:设置代理

如果你所在网络无法直接访问 GitHub / openclaw.ai 等境外站点(下载缓慢或超时),需要为终端和 npm 设置代理。假设你的代理地址为 http://127.0.0.1:7890,执行:

# 当前终端会话生效(PowerShell)
$env:HTTP_PROXY = "http://127.0.0.1:7890"
$env:HTTPS_PROXY = "http://127.0.0.1:7890"

# npm 设置代理
npm config set proxy http://127.0.0.1:7890
npm config set https-proxy http://127.0.0.1:7890

# 取消代理(不需要时恢复)
npm config delete proxy
npm config delete https-proxy

将 127.0.0.1:7890 替换成你自己的代理地址和端口即可。

安装过程遇到无法访问服务器问题“Failed to connect to github.com port 443 after 22141 ms: Could not connect to server”,那么需要修改请求源为国内源试试。
npm config set registry https://registry.npmmirror.com
git config --global url."https://github.com.cnpmjs.org/".insteadOf https://github.com/
如果执行了上面的请求源切换后还不行的话,可以再接着挨个试试下面这些源。
# FastGit (推荐,比淘宝镜像更适配 Git 操作)
git config --global url."https://hub.fastgit.xyz/".insteadOf https://github.com/
# GitClone (适合克隆大仓库)
git config --global url."https://gitclone.com/github.com/".insteadOf https://github.com/
# GHProxy (兜底方案,兼容性最强)
git config --global url."https://ghproxy.com/https://github.com/".insteadOf https://github.com/

4.3 使用加速器(可选)

如果你使用了 Clash、v2rayN、Shadowrocket 等加速/代理工具,最省事的方式是直接开启它们的「系统代理」开关,或开启 TUN / 虚拟网卡模式,让整台电脑(包括 PowerShell 终端和 npm)的流量都自动走代理,无需手动设置环境变量。开启后,上面 4.2 的手动代理设置通常就不用重复配置了。

判断代理是否生效:在 PowerShell 中执行 curl.exe https://www.google.com -I,如果能返回 HTTP/2 200 之类的状态码,说明代理已生效。

4.4 设置 npm 淘宝镜像

国内网络访问 npm 官方源较慢,建议将 npm 镜像切换到淘宝源(npmmirror):

# 查看当前镜像
npm config get registry

# 设置为淘宝镜像
npm config set registry https://registry.npmmirror.com

# 恢复官方源(需要时)
npm config set registry https://registry.npmjs.org

4.5 配置 Git 代理、加速拉取 GitHub 代码

Git 克隆 GitHub 仓库时经常超时,可单独为 Git 配置代理:

# 为 Git 设置代理(替换成你的代理地址)
git config --global http.proxy http://127.0.0.1:7890
git config --global https.proxy http://127.0.0.1:7890

# 取消 Git 代理
git config --global --unset http.proxy
git config --global --unset https.proxy

如果不想用代理,也可以把 GitHub 相关操作走加速镜像或代理地址:

# 克隆时使用镜像加速(示例)
git clone https://gitclone.com/github.com/openclaw/openclaw.git

# 或使用 GitHub 代理前缀(示例)
git clone https://ghproxy.com/https://github.com/openclaw/openclaw.git
git config --global url."https://github.com.cnpmjs.org/".insteadOf https://github.com/

五、安装 OpenClaw

前置依赖就绪后,即可安装 OpenClaw。推荐使用官方的一键安装脚本(PowerShell):

iwr -useb https://openclaw.ai/install.ps1 | iex

备选 B:Gitee 镜像版脚本(上面的链接打不开时用)

iwr -useb https://gitee.com/openclaw/install/raw/main/install.ps1 | iex

方案 C:手动前置优化脚本(如果你想用官方原版 install.ps1,先执行下面这段)

适合想直接跑官方原版脚本,但提前配置国内 npm 源,避免 npm 安装 openclaw 包超时 管理员 PowerShell 执行:

# 设置npm淘宝镜像
npm config set registry https://registry.npmmirror.com
# 关闭严格ssl校验(国内网络偶尔证书报错,安装完成后可恢复)
npm config set strict-ssl false
# 配置git代理,github拉代码加速
git config --global url."https://ghproxy.net/https://github.com/".insteadOf "https://github.com/"

执行完上面,再执行官方原版安装命令

iwr -useb https://openclaw.ai/install.ps1 | iex

恢复 ssl(安装完成后建议执行)

npm config set strict-ssl true

国内环境额外注意事项(重点)

  1. 网络区分
    • 脚本下载 Node/Git 可以国内直连;大模型 API(OpenAI/Anthropic)仍然需要外网;
    • 如果你只用 Ollama 本地模型,不需要外网,仅安装阶段需要网络下载 npm 包。
  2. 防火墙 / 杀毒 Windows Defender、360 等会拦截脚本自动下载文件,安装过程临时关闭安全软件,否则中途中断。
  3. 脚本卡住处理
    • 长时间卡在installing openclaw:大概率 npm 包下载慢,终止终端,重新执行脚本;
    • 报错openclaw不是命令:安装结束必须完全关闭所有 PowerShell 窗口,重新打开,PATH 环境变量才生效。
  4. 镜像回滚(后续切回官方源)
npm config set registry https://registry.npmjs.org
git config --global --unset url."https://ghproxy.net/https://github.com/".insteadOf

安装完成后校验命令(不变)

openclaw --version
openclaw doctor
openclaw onboard

常见国内特有报错

  1. connect to github.com:443 timeout
    • 改用【方案 A】社区镜像脚本,内置 ghproxy 自动替换 github 地址。
  2. npm ERR network timeout
    • 确认 npm 源已经是 npmmirror,重新运行脚本。
  3. 中文乱码
& {$w=New-Object Net.WebClient;$w.Encoding=[Text.Encoding]::UTF8;iex $w.DownloadString('https://openclawal.cn/scripts/install.ps1')}
  • 开启 PowerShell 远程脚本执行权限(否则安装脚本无法运行)
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

输入Y确认。 校验是否生效:

Get-ExecutionPolicy -Scope CurrentUser
OpenClaw 安装过程 1
OpenClaw 安装过程 2


如果你习惯手动管理 npm,也可以使用:

npm install -g openclaw@latest --allow-scripts=openclaw
openclaw onboard --install-daemon
  • 安装后校验
# 查看版本
openclaw --version
# 全面健康检查(推荐)
openclaw doctor
# 查看网关服务状态
openclaw gateway status
  • 常用管理命令
# 启动初始化向导
openclaw onboard --install-daemon

# 停止网关
openclaw gateway stop

# 手动启动网关
openclaw gateway start

# 完全卸载OpenClaw
npm uninstall -g openclaw
Remove-Item -Recurse -Force $env:USERPROFILE\.openclaw -ErrorAction SilentlyContinue

六、初始化配置

安装完成后运行以下命令进入引导配置,按提示完成身份、渠道等设置:

openclaw onboard --install-daemon
openclaw onboard
初始化配置步骤 1
初始化配置步骤 2
初始化配置步骤 3
初始化配置步骤 4
初始化配置步骤 5
初始化配置步骤 6
初始化配置步骤 7

七、验证安装并启动网关

最后验证安装是否成功:

openclaw --version
openclaw doctor
openclaw gateway status

如果需要开机自启、后台常驻,可以安装 Gateway 服务:

openclaw gateway install

结语

至此,OpenClaw 已在你的 Windows 11 电脑上安装完成。你可以通过 openclaw 命令管理网关、连接消息渠道,开始与你的 AI 助手对话。如果遇到 openclaw: command not found 之类的报错,通常是 npm 全局 bin 目录不在 PATH 中,可参考官方文档排查。

电脑重新安装操作系统,如何备份迁移Openclaw:https://www.hao0564.com/6207.html

Winget命令详解和应用:https://www.hao0564.com/6003.html

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注