Skip to content

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).

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:

apps.json
{
"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).

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.

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:

command
npm run dev -- --port 5173 --strictPort

If the port is already taken, see Fix EADDRINUSE and “Port 5173 is in use”.

Moonpool is free software from FasterDB