mustache-js views don't auto-refresh with nodemon

1.5k views Asked by At

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.

3

There are 3 answers

0
ripper234 On BEST ANSWER

From this answer I changed my start script to

"start": "nodemon -e js,mustache ./server.js",

1
Brian Min On

Changing the html mustache templates wont cause the server to restart using nodemon.

But in my case, i can simply edit an html mustache template file, save it, and refresh the page (without restarting the server) and i can see the changes made.

Perhaps, try checking your routing and make sure you are rendering the correct template files.

0
Noam Manos On

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