nodemon is a lovely little tool for watching for changes to node.js source code and automatically restarting your server during development.
There are a number of solutions available for restarting your node.js server when you update your source code (e.g., forever, up, etc.). Some of these have advanced features like running as a background service and load balancing that are useful in a production environment. However, the simplest tool I’ve found so far for development use is Remy’s nodemon.
npm install -g nodemon
That will get it to run my-server.js and also watch the folder that the script is in in for changes to any of the files. When a file does change, it will restart your server using the latest code. Of the similar tools I’ve tried, nodemon was the fastest to react to changes (hey, those precious seconds add up when you’re continuously testing your scripts).
Did someone say ‘CoffeeScript?’
As an awesome little side benefit, nodemon can also directly run and watch a server written in CoffeeScript:
coffee --compile --watch my-server.coffee
This will save my-server.js and restart the server any time you update your code.