Skip to content

Instantly share code, notes, and snippets.

@aidev13
Last active March 18, 2025 20:40
Show Gist options
  • Save aidev13/e3c2ffab78f5611aa3e46e3f16238d61 to your computer and use it in GitHub Desktop.
Save aidev13/e3c2ffab78f5611aa3e46e3f16238d61 to your computer and use it in GitHub Desktop.
Instead of nodemon, use this!

Instead of nodemon, use this!

Nodemon is a great tool for node, but node has: --watch.

Instead of:

npm nodemon script.js

use:

node --watch script.js

No need to NPM nodemon! Happy Coding!

@aidev13
Copy link
Author

aidev13 commented Mar 18, 2025

UPDATE::

I have been running into issues with node --watch... here is why

node --watch is built into Node.js and watches for file changes, but it doesn’t always clean up the previous process properly, which can lead to that EADDRINUSE error.

Why?

node --watch restarts the server when changes happen, but sometimes the old process doesn’t fully release the port before the new one starts.
nodemon handles this better by properly shutting down the old instance before restarting.

Stick with nodemon
It’s just more reliable for restarting servers without causing port issues. But if you still prefer node --watch, you might need to manually kill the process sometimes (taskkill or kill -9 ).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment