From ab1b76dd47341621de3c39c4ef77e58cb030184e Mon Sep 17 00:00:00 2001 From: oliver Date: Wed, 6 May 2026 17:38:14 +0800 Subject: [PATCH] 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 --- scripts/start_netx.ps1 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/scripts/start_netx.ps1 b/scripts/start_netx.ps1 index 6eb921a..61bf279 100644 --- a/scripts/start_netx.ps1 +++ b/scripts/start_netx.ps1 @@ -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"