Nodemon + babel restart the server multiple times

So in case someone stumbles on this like I did.

While the delay works, it works because your build takes less than 2s usually.

This can lead to it being flakey, or just take longer than it needs.

The correct solution is to actually ignore the output directory, or file within nodemon.

NODE_PATH=src nodemon --watch src/ --exec babel-node src/app.js --out-file dist/app.js -- dist/app.js


So, now a couple of months later i figured out what's wrong. Seems like the server simply restarts once when I save and the once again when babel transformed the code a couple of seconds later since the files get updated. So it was the package babel-node that was giving me this unwanted behaviour. It works with a nodemon delay of 2 seconds --delay 2 or more.


You should use babel-node as an executor like this:

nodemon ./index.js --exec babel-node