I have been playing around with Node.js on and off now for quite some time. And one thing that have bothered me is the simple fact that I had to restart the node server process every time I made the slightest changes to any server side code. Normally I would have given up much earlier and start looking for a way to get around it. But since I never really stuck with Node for any longer period of time, I never got to it.
Well, recently I stumbled on to a solution. A very nice little npm package called nodemon. What it does is it wraps around the node command and monitors for any changes in the code. And as soon as it notices any changes, it restarts the node server process for you.
To install it, just type the following command
$ npm install -g nodemon
Note that depending on the location for you global packages, you might have to use
sudo in front of the command. The
-g flag is of course to install it globally since this package should not be included into any specific project. It is more of a development tool.
To use nodemon with your node server process, just replace the
node command with
nodemon instead. For example:
$ nodemon app.js
For more information, take a look at the documentation here