- 下载node.js (LTS),安装在无中午路径下,D盘
官网下载:https://nodejs.org/ (选左侧绿色 LTS);
环境变量中添加到PATH(系统变量);
验证:
powershell
node -v
npm -v
- 下载git
官网下载:https://git-scm.com/
验证:
powershell
git --version
- 先彻底清理以前的openclaw(复制运行)
powershell
npm uninstall -g openclaw
rm -r "$env:USERPROFILE\openclaw" -ErrorAction SilentlyContinue
rm -r "$env:USERPROFILE\.openclaw" -ErrorAction SilentlyContinue
npm cache clean --force
7.强制安装到 D 盘纯英文路径
在D盘创建npm-global文件夹
运行:
powershell
# 强制把全局安装位置改到 D 盘(解决中文路径)
npm config set prefix D:\npm-global
8.把 D:\npm-global 加入 PATH(必须做)
9.按实际情况选择
powershell
# 临时把用户目录改成D盘,让安装脚本不进中文目录
$env:USERPROFILE = "D:\"
9.强制全局安装(正确方法!)
powershell
npm install -g openclaw --registry=https://registry.npmmirror.com
10.右键 D:\npm-global\openclaw.cmd → 用记事本打开,全选删除原有内容,粘贴下面这段:
powershell
@ECHO off
SETLOCAL
SET "OPENCLAW_ROOT=D:\npm-global\node_modules\openclaw-cn"
node "%OPENCLAW_ROOT%\dist\entry.js" %*
ENDLOCAL
11.在同目录下找到 openclaw(无后缀的文件),用记事本打开,替换为:
powershell
#!/bin/sh
exec node "D:/npm-global/node_modules/openclaw-cn/dist/entry.js" "$@"
验证:
powershell
# 查看 openclaw 命令位置
where.exe openclaw
# 查看 npm 全局根目录
npm root -g
# 检查 entry.js 是否存在
Test-Path "D:\npm-global\node_modules\openclaw-cn\dist\entry.js"
正常输出:
D:\npm-global\openclaw.cmd、D:\npmglobal\node_modules、True,说明配置完全正确。
12.配置model
powershell
openclaw config
13.配置channel
14.启动
powershell
openclaw gateway run
openclaw dashboard