A simple Node.js watcher that automatically reloads a script on changes.
node watcher.js your_script.js
This tool was made as an experiment when I started to work with Node.js years ago.
I recommend using existing tools such as Nodemon which is suitable and provides more features.
Also, Node.js 19 adds a node --watch
CLI option to run a script in "watch" mode without having to install any package.