Nodemon not restarting when html file is modified

Hom nom nom nom ... picture Hom nom nom nom ... · Jun 9, 2016 · Viewed 20.6k times · Source

I'm learning Node.js, my demo has two files:

  • /server.js
  • /public/index.html

/server.js will get /public/index.html and then return to the client.

I'd like to use nodemon to auto reload when /public/index.html is modified. However, it seems like nodemon only works when I modify /server.js and not when /public/index.html is modified.

I'm using nodemon server.js to starting the server.

Answer

Traveling Tech Guy picture Traveling Tech Guy · Jun 9, 2016

Just specify watching html on the nodemon command line (or better yet, add a config file).

From the documentation:

By default, nodemon looks for files with the .js, .coffee, .litcoffee, and .json extensions. If you use the --exec option and monitor app.py nodemon will monitor files with the extension of .py. However, you can specify your own list with the -e (or --ext) switch like so:

nodemon -e js,jade Now nodemon will restart on any changes to files in the directory (or subdirectories) with the extensions .js, .jade.