6

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.

ripper234
  • 222,824
  • 274
  • 634
  • 905

3 Answers3

3

From this answer I changed my start script to

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

Community
  • 1
  • 1
ripper234
  • 222,824
  • 274
  • 634
  • 905
1

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
Noam Manos
  • 15,216
  • 3
  • 86
  • 85
0

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.

Brian Min
  • 265
  • 4
  • 10
  • I am rendering the correct file ... but on my setup I have to restart the node server for the changes in mustache files to take effect. – ripper234 Jan 07 '17 at 13:46