feat(start): auto-install web dependencies when WithWeb is enabled

Install frontend npm dependencies automatically in start_netx so fresh machines can bring up the 5173 Vite UI without separate manual npm install.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-05-06 17:38:14 +08:00
parent d529ff70ff
commit ab1b76dd47

View file

@ -44,6 +44,24 @@ if (-not $SkipInstall) {
Write-Host "==> Skip dependency install (if API fails with ModuleNotFoundError, run once without -SkipInstall)"
}
if ($WithWeb) {
$webRoot = Join-Path $projectRoot "web"
$webNodeModules = Join-Path $webRoot "node_modules"
if (-not (Get-Command "npm.cmd" -ErrorAction SilentlyContinue)) {
throw "npm_not_found: install Node.js (includes npm) and reopen terminal"
}
$needWebInstall = (-not (Test-Path $webNodeModules)) -or (-not $SkipInstall)
if ($needWebInstall) {
Write-Host "==> Installing web dependencies (npm install)"
& npm.cmd install --prefix $webRoot
if ($LASTEXITCODE -ne 0) {
throw "npm_install_failed"
}
} else {
Write-Host "==> Skip web dependency install (node_modules exists)"
}
}
$env:NETX_HOST = $BindHost
$env:NETX_PORT = "$Port"
$baseUrl = "http://$BindHost`:$Port"