Tooling

Restarting a Node server on save, without nodemon

node --watch restarts the process when a file it loaded changes. It replaced a dependency and a config file in stummel.

0:00
/0:07
Save, restart, curl. The clip loops.

node --watch restarts the process when any file it imported changes. It has been stable since Node 22, and it replaced nodemon and its config file in stummel.

{
  "scripts": {
    "dev": "node --watch src/server.ts" // [!code ++]
    "dev": "nodemon --exec node src/server.ts" // [!code --]
  }
}

Where it falls short

It watches what the process loaded, not the folder. A template read with readFile does not restart it. --watch-path=templates adds that folder.

Comments

Buy Logbuch