(Like how I totally made that epic gruntjs logo with the watch on it’s face, for grunt-contrib-watch? I’m such a rock-star designer. You should totally hire me for my hawt photoz skillz! :P)
I’ve been using both Nodemon and grunt-contrib-watch a lot in the last month. These are both great tools, and I think anyone working with NodeJS should at least have these in your “I’m familiar with” category. But for as much as I’ve been using these tools lately, I keep asking myself “why am I using both of these? why not stick to one of them?” … and as I sat here, thinking about the projects I’m currently working on, wondering if I could switch everything over to one of them, the difference between Nodemon and grunt-contrib-watch suddenly hit me.
The core of Nodemon is a tool that replaces the standard “node” command line, with the goal of restarted the node app whenever a file changes. You just replace “node” with “nodemon” on the command line, for the most part.
Nodemon will foward the command to the normal node process and then monitor the file system for changes. When a file that nodemon is watching has changed, nodemon will stop the node process and restart it. This is great for building node apps that are long-living, like ExpressJS web apps. Instead of having to stop and restart the server all the time, you just let nodemon do it for you (for the WatchMeCode subscribers in the audience, I have a screencast showing exactly this).
Nodemon makes life simple, when it comes time to restart your node process based on files changing.
This is a tool that also watches for file system changes. But rather than re-starting a process when something changes, it allows you to do a number of other things including running various grunt tasks.
So, What’s The Difference?
Should I Use Both?
In the end, I realized that these tools are very complementary to each other. They go hand in hand, creating an epic development environment for your NodeJS applications. So, yes. Use both because they serve a different purpose, in spite of having similar mechanics.