Run an npm dev server in the background on Windows without a terminal window
A dev server started with npm run dev runs in the terminal that launched it, so closing
that window ends it. The plain Windows way to keep it going is a hidden process, for example
Start-Process npm.cmd -ArgumentList "run","dev" -WindowStyle Hidden in PowerShell, but then
you have no output to read and stopping it means hunting for the right node.exe (see
Find and kill the process using a port).
The Moonpool way
Section titled “The Moonpool way”Moonpool runs the command in its own embedded terminal tab inside the hub window, so there is no separate console window to keep open. Hide the hub to the tray and the server keeps running. Add the app once:
{ "id": "site", "name": "Site", "group": "Web apps", "type": "web", "cwd": "C:\\code\\site", "command": "npm run dev", "port": 5173, "url": "http://localhost:5173", "openBrowser": true}Click the app’s Launch control. The status dot is solid once port answers, and the
browser opens to url because of openBrowser. Click the app’s name to read its output in
its own tab. Stop ends the terminal and everything it started, and frees the port
(killMode port is the default for web).
Keep it running when you close the window
Section titled “Keep it running when you close the window”By default the close button quits Moonpool, and on Windows quitting stops every app it launched. Turn on Close to tray in Settings, and closing the window only hides it. The tray icon (or Show Moonpool) brings it back. Details are in Tray, close and minimize.
Keep the port predictable
Section titled “Keep the port predictable”Moonpool decides Running from port. Vite moves to the next free port when its port is
taken, which would leave Moonpool watching the wrong one. Pass --strictPort so Vite
exits instead, and set port to match:
npm run dev -- --port 5173 --strictPortIf the port is already taken, see Fix EADDRINUSE and “Port 5173 is in use”.
Limits
Section titled “Limits”- Moonpool does not restart a server that crashes. It shows the app as stopped and the tab
prints
[process exited]. - Moonpool does not start by itself at Windows login. See Start a script or dev server automatically at Windows login.
See also
Section titled “See also”- App fields:
port,openBrowser,killMode. - App types: how Running is decided for
web. - Stop and restart
- Examples
Moonpool is free software from FasterDB