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
This commit is contained in:
dongsheng123132
2026-03-18 16:06:15 +08:00
parent 08a913c21c
commit 71d76a4055
2 changed files with 22 additions and 4 deletions

View File

@@ -145,6 +145,9 @@ if (-not $USE_SYSTEM_NODE) {
exit 1 exit 1
} }
} }
# 把下载的 Node 加到 PATH让 npm.cmd 能找到 node.exe
$env:PATH = "$NODE_INSTALL_DIR;$env:PATH"
} }
Write-Host "" Write-Host ""
@@ -172,7 +175,12 @@ if (Test-Path "$CORE_DIR\node_modules\openclaw") {
Write-Cyan " ↓ 从国内镜像安装..." Write-Cyan " ↓ 从国内镜像安装..."
Push-Location $CORE_DIR 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 Pop-Location
Write-Green " ✓ OpenClaw 安装完成" Write-Green " ✓ OpenClaw 安装完成"
} }
@@ -190,10 +198,11 @@ if (Test-Path "$CORE_DIR\node_modules\@sliverp\qqbot") {
Write-Cyan " ↓ 安装 QQ 插件..." Write-Cyan " ↓ 安装 QQ 插件..."
try { try {
Push-Location $CORE_DIR 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 Pop-Location
Write-Green " ✓ QQ 插件安装完成" Write-Green " ✓ QQ 插件安装完成"
} catch { } catch {
Pop-Location
Write-Yellow " ⚠ QQ 插件安装失败(不影响主功能)" Write-Yellow " ⚠ QQ 插件安装失败(不影响主功能)"
} }
} }

View File

@@ -145,6 +145,9 @@ if (-not $USE_SYSTEM_NODE) {
exit 1 exit 1
} }
} }
# 把下载的 Node 加到 PATH让 npm.cmd 能找到 node.exe
$env:PATH = "$NODE_INSTALL_DIR;$env:PATH"
} }
Write-Host "" Write-Host ""
@@ -172,7 +175,12 @@ if (Test-Path "$CORE_DIR\node_modules\openclaw") {
Write-Cyan " ↓ 从国内镜像安装..." Write-Cyan " ↓ 从国内镜像安装..."
Push-Location $CORE_DIR 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 Pop-Location
Write-Green " ✓ OpenClaw 安装完成" Write-Green " ✓ OpenClaw 安装完成"
} }
@@ -190,10 +198,11 @@ if (Test-Path "$CORE_DIR\node_modules\@sliverp\qqbot") {
Write-Cyan " ↓ 安装 QQ 插件..." Write-Cyan " ↓ 安装 QQ 插件..."
try { try {
Push-Location $CORE_DIR 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 Pop-Location
Write-Green " ✓ QQ 插件安装完成" Write-Green " ✓ QQ 插件安装完成"
} catch { } catch {
Pop-Location
Write-Yellow " ⚠ QQ 插件安装失败(不影响主功能)" Write-Yellow " ⚠ QQ 插件安装失败(不影响主功能)"
} }
} }