From 71d76a40559970e6b85f13dbf32758723233dce0 Mon Sep 17 00:00:00 2001 From: dongsheng123132 <90887123+dongsheng123132@users.noreply.github.com> Date: Wed, 18 Mar 2026 16:06:15 +0800 Subject: [PATCH] fix: Windows npm.cmd cannot be executed by node.exe directly On Windows, npm.cmd is a batch wrapper, not a JS file. Calling `node.exe npm.cmd install` causes loader errors. Fix: - Add downloaded Node dir to PATH so npm.cmd can find node.exe - Call `npm.cmd install` directly instead of `node.exe npm.cmd install` - Add error handling for OpenClaw install failure --- install/install.ps1 | 13 +++++++++++-- website/install.ps1 | 13 +++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/install/install.ps1 b/install/install.ps1 index a174e02..acb2140 100644 --- a/install/install.ps1 +++ b/install/install.ps1 @@ -145,6 +145,9 @@ if (-not $USE_SYSTEM_NODE) { exit 1 } } + + # 把下载的 Node 加到 PATH,让 npm.cmd 能找到 node.exe + $env:PATH = "$NODE_INSTALL_DIR;$env:PATH" } Write-Host "" @@ -172,7 +175,12 @@ if (Test-Path "$CORE_DIR\node_modules\openclaw") { Write-Cyan " ↓ 从国内镜像安装..." Push-Location $CORE_DIR - & $INSTALL_NODE $INSTALL_NPM install --registry=$MIRROR 2>&1 | Select-Object -Last 5 + & $INSTALL_NPM install --registry=$MIRROR 2>&1 | Select-Object -Last 5 + if ($LASTEXITCODE -ne 0) { + Write-Red " ✗ OpenClaw 安装失败,请检查网络" + Pop-Location + exit 1 + } Pop-Location Write-Green " ✓ OpenClaw 安装完成" } @@ -190,10 +198,11 @@ if (Test-Path "$CORE_DIR\node_modules\@sliverp\qqbot") { Write-Cyan " ↓ 安装 QQ 插件..." try { Push-Location $CORE_DIR - & $INSTALL_NODE $INSTALL_NPM install "@sliverp/qqbot@latest" --registry=$MIRROR 2>&1 | Out-Null + & $INSTALL_NPM install "@sliverp/qqbot@latest" --registry=$MIRROR 2>&1 | Out-Null Pop-Location Write-Green " ✓ QQ 插件安装完成" } catch { + Pop-Location Write-Yellow " ⚠ QQ 插件安装失败(不影响主功能)" } } diff --git a/website/install.ps1 b/website/install.ps1 index a174e02..acb2140 100644 --- a/website/install.ps1 +++ b/website/install.ps1 @@ -145,6 +145,9 @@ if (-not $USE_SYSTEM_NODE) { exit 1 } } + + # 把下载的 Node 加到 PATH,让 npm.cmd 能找到 node.exe + $env:PATH = "$NODE_INSTALL_DIR;$env:PATH" } Write-Host "" @@ -172,7 +175,12 @@ if (Test-Path "$CORE_DIR\node_modules\openclaw") { Write-Cyan " ↓ 从国内镜像安装..." Push-Location $CORE_DIR - & $INSTALL_NODE $INSTALL_NPM install --registry=$MIRROR 2>&1 | Select-Object -Last 5 + & $INSTALL_NPM install --registry=$MIRROR 2>&1 | Select-Object -Last 5 + if ($LASTEXITCODE -ne 0) { + Write-Red " ✗ OpenClaw 安装失败,请检查网络" + Pop-Location + exit 1 + } Pop-Location Write-Green " ✓ OpenClaw 安装完成" } @@ -190,10 +198,11 @@ if (Test-Path "$CORE_DIR\node_modules\@sliverp\qqbot") { Write-Cyan " ↓ 安装 QQ 插件..." try { Push-Location $CORE_DIR - & $INSTALL_NODE $INSTALL_NPM install "@sliverp/qqbot@latest" --registry=$MIRROR 2>&1 | Out-Null + & $INSTALL_NPM install "@sliverp/qqbot@latest" --registry=$MIRROR 2>&1 | Out-Null Pop-Location Write-Green " ✓ QQ 插件安装完成" } catch { + Pop-Location Write-Yellow " ⚠ QQ 插件安装失败(不影响主功能)" } }