From 88cf2b2dc49c8a569a5d0a3e49c4e7c05e3f6abe Mon Sep 17 00:00:00 2001 From: hfshfg <38004547@qq.com> Date: Fri, 1 May 2026 15:29:04 +0800 Subject: [PATCH] fix(portable/setup.ps1): cd to core dir before npm install When users run setup.ps1 from PowerShell with cwd outside the repo (e.g. C:\Users\Admin>), npm 11 walks up looking for package.json and errors with ENOENT before honoring --prefix. setup.bat already pushd's into core; setup.ps1 was missing the equivalent Push-Location guard. Fixes #27 (setup.ps1 ENOENT package.json reported by lawler-code). --- portable/setup.ps1 | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/portable/setup.ps1 b/portable/setup.ps1 index 3b101f2..bea0ce8 100644 --- a/portable/setup.ps1 +++ b/portable/setup.ps1 @@ -224,7 +224,13 @@ if (Test-Path -Path (Join-Path $coreDir "node_modules\openclaw") -PathType Conta } else { Write-Step "->" "Installing OpenClaw..." "Cyan" - & $npmCmd install --prefix $coreDir --registry=$mirror + Push-Location $coreDir + try { + & $npmCmd install --prefix $coreDir --registry=$mirror + } + finally { + Pop-Location + } if (Test-Path -Path (Join-Path $coreDir "node_modules\openclaw") -PathType Container) { Write-Step "OK" "OpenClaw installation completed." "Green" @@ -240,11 +246,15 @@ if (Test-Path -Path (Join-Path $coreDir "node_modules\@sliverp\qqbot") -PathType } else { Write-Step "->" "Installing QQ plugin..." "Cyan" + Push-Location $coreDir try { - & $npmCmd install @sliverp/qqbot@latest --prefix $coreDir --registry=$mirror 2>$null + & $npmCmd install "@sliverp/qqbot@latest" --prefix $coreDir --registry=$mirror 2>$null } catch { } + finally { + Pop-Location + } Write-Step "OK" "QQ plugin installation finished." "Green" }