Node.js 版本不兼容
OpenClaw 需要 Node.js 22+,当前版本过低导致安装失败
❌ 错误信息
# 错误示例
openclaw: requires Node.js >= 22.0.0, but the loaded version is v18.19.0
# 或
node: --openssl-legacy-provider is not allowed
解决方案
方案一:使用 nvm 管理 Node.js 版本(推荐)
# 安装 nvm (Linux/macOS)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
source ~/.bashrc
# 安装 Node.js 22
nvm install 22
nvm use 22
# 设置默认版本
nvm alias default 22
# 验证
node --version
方案二:使用 fnm 管理 Node.js(更快)
# 安装 fnm
curl -fsSL https://fnm.install | bash
source ~/.bashrc
# 安装并使用 Node.js 22
fnm install 22
fnm use 22
fnm default 22
方案三:使用 NodeSource 安装
# Ubuntu/Debian
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt install -y nodejs
# 验证
node --version
方案四:Windows 安装
下载并安装 Node.js 22 LTS:
https://nodejs.org/建议使用 nvm-windows:
https://github.com/coreybutler/nvm-windows方案五:Docker(最简单)
# 使用官方 Docker 镜像(内置 Node.js 22)
docker pull openclaw/openclaw:latest
docker run -d --name openclaw -p 18789:18789 openclaw/openclaw:latest
检查当前 Node.js 版本
node --version
npm --version
# 或
nvm ls
常见问题
Q: nvm 命令找不到?
需要重新加载配置文件:
source ~/.bashrc # bash
source ~/.zshrc # zsh
source ~/.profile # 系统默认
Q: 升级后还是显示旧版本?
需要先关闭当前终端,重新打开一个终端