I've been using nodemon for a while to save me the trouble of restarting the server whenever I edit a file.
Now I switched to using mustache.js templates, and the magically-always-up-to-date ceased to work - I now need to manually restart the server for my changes to take effect.
Is this a bug? Misconfiguration?
To clarify: whenever I edit a .mustache file, I need to manually restart the server to see my changes.
From this answer I changed my start script to
"start": "nodemon -e js,mustache ./server.js",
In order to specify on which files Nodemon should auto-refresh, you can set package.json to start Nodemon with a nodemon.json configuration file, that includes the file extensions to watch. For example:
Add to package.json file:
"scripts": {
"dev": "nodemon --config nodemon.json"
},
Create nodemon.json file:
{
"verbose": true,
"execMap": {
"js": "node --harmony"
},
"script": "server.js",
"ext": "js mustache"
}
Now when running, you should see that nodemon is watching for .js and .mustache files:
> npm run dev
[nodemon] 1.11.0
[nodemon] reading config nodemon.json
[nodemon] watching extensions: js,mustache
[nodemon] starting `node --harmony server.js`
[nodemon] child pid: 7740
[nodemon] watching 5 files
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With