node.jsservervitewatchtypescript-execute

Multiple 'Restarting server/server.js' messages when using 'tsx --watch' in script


I've added a tsx --watch command to my package.json scripts to watch changes in my server file. Here's the relevant part of my package.json:

"scripts": {
  "dev": "concurrently \"tsx --watch server/server.js\" \"vite --port=3000 --host --open\""
}

When I run pnpm run dev, the server works as intended, but I get tens of 'Restarting 'server/server.js'' messages:

[0] Restarting 'server/server.js'.
[0] Restarting 'server/server.js'.
[0] Restarting 'server/server.js'.
...

I don't understand where these duplicates are coming from. How can I fix this issue and prevent the multiple restart messages? Looking for a possible solution.


Solution

  • use tsx watch instead of tsx --watch

    https://tsx.is/watch-mode