I am using express and every time I make a change to my controller, I need to restart the HTTP server, which is somewhat inconvenient. Is there a "watch" command or an equivalent in express or Node.js that watches for changes and restarts the server automatically?
Node. js has a built-in module called HTTP, which allows Node. js to transfer data over the Hyper Text Transfer Protocol (HTTP). The HTTP module can create an HTTP server that listens to server ports and gives a response back to the client.
Node.js has a built-in module called HTTP, which allows Node.js to transfer data over the Hyper Text Transfer Protocol (HTTP). To include the HTTP module, use the require() method: var http = require('http');
Try nodemon, it will restart your application every time you made a change
To watch files for changes, you could use fs.watch()
or fs.watchFile()
. However, daemon modules such as supervisor or nodemon exist for your purpose.
I use node-dev for automatic restart on source code change.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With