I'm using 'nodemon' to restart node on file changes. However it doesn't seem to trigger when json files have changed. Anyone know if there is a way to set this up?
Also, is there a programmatic way to restart from within the running app itself? I suppose running it with 'forever' and throwing an error would do it. Any pointers much appreciated
Just use "-e" command line switch
Unfortunately the extensions that it monitors seem to be hardcoded in the script:
https://github.com/remy/nodemon/blob/master/nodemon.js#L334
program.ext = '.coffee|.js';
You could hack it to make it work for json as well:
git clone https://github.com/remy/nodemon.git
cd nodemon
Modify that line in nodemon.js
to program.ext = '.coffee|.js|.json';
npm install -g .
(it should use the cloned git folder instead of the npm registry)
Or you could use my script, although it's less stable than nodemon.
Marciej's approach worked for me:
nodemon -e js,html
You can also configure this in a nodemon.json
config file. Here's how we're currently using it:
{
"execMap": {
"js": "node --harmony"
},
"script": "server.js",
"ext": "js html"
}