Watch your Code for Changes!

Matthias Gattermeier
Node and Beyond
Published in
1 min readAug 7, 2015

--

Among the most annoying things when developing is needing to constantly recompile and / or restart your application after making changes to your codebase.

There are a few ways of getting around that, and here my favorites (which you can chain together :)

Node.js

If you develop a lot with Node.js, you might already have heard about nodemon. This amazing little plugin watches your node application for changes and restart whenever you save code changes. Install it globally with:

npm install -g nodemon

and run it in your terminal simply with:

nodemon yourapp.js

Coffeescript

Watch your coffeescript code for changes and auto-recompile into your folder of choice with a simple command in your terminal, like so:

coffee -output compiled -map -watch -compile ./

Grunt

If you use grunt, you can use the grunt-contrib-watch plugin to watch for file changes and run your tests automagically. Your Gruntfile.js should look something like this:

Grunfile example for a Node.js App

If you read this, I hope it helps you save some time by eliminating some of those repetitive tasks.

Cheers

--

--