Nodemon – Restarting Node Automatically

Asif Ahmed

Whenever I am developing anything in Node, I find myself stopping and starting the Node server often everytime I make a change. Though initially you might just deal with this annoyance, it can become rather frustrating later on. My development environment consists of three screens, one with Sublime Text running for my code, one with Chrome running so I can test my application, and the last one running with Chrome so I can hit up Google and StackOverflow for looking up development solutions. When you are developing with Node you also need a terminal window open where you run commands for installing npm packages, installing bower components, or (most of the time) stopping and starting Node.

There is (there usually is) a beautiful solution to this problem. A whole list of solutions can be found at this blog, but my preferred method is to use Nodemon. Plus it sounds cool (kind of like Pokémon). Use npm to install Nodemon globally.

Then instead of using Node to start your server (node server.js) use Nodemon instead:

It will restart your server whenever you make a change to a JS file. This should definitely make Node development a lot easier!

To check out more information about this topic, check out this SO link – http://stackoverflow.com/questions/11175676/restart-node-upon-changing-its-file.