/ nodemon

Fix nodemon continuous reload with scribe-js

While logging using Scribe JS with nodemon, I was facing an issue where nodemon will continuously restart with following message and go into endless loop:

Magic happens on port 4000
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] starting `node index.js`
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] starting `node index.js`

Only after spending about an hour, I realised that this was happening because scribe-js was writing .json files into the root directory under logs folder by default. As soon as you import it via:

const scribe = require('scribe-js')()

nodemon was considering this as file change and restarting the app immediately.

Solution
Instruct nodemon not to watch the files under logs directory by adding a file nodemon.json in the root directory with content:

{
  "ignore": ["logs/*"] 
}

You can also pass this as command line argument:

nodemon --ignore 'logs/*'