Nodemon not restarting when html file is modified

26,333

Solution 1

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.

Solution 2

Add nodemon.json configuration file worked for me.

{
  "ext": "html"
}

Solution 3

Use a comma separated string to add multiple extensions in nodemon.json

{
    "ext": "js,html"
}

Solution 4

Here's another possibility: using your existing package.json file:

"name": "app",
"version": "1.0.0",
"nodemonConfig": {
  "ext": "js,html"
}

Just keep in mind nodemon will only be checking for .js and .html files from now on. You'll have to add your own files if you have more.

Solution 5

Add watching extension for all in package.json file do something like with your scripts:

"scripts": {
    "start": "nodemon -e * app.js"
  }

This worked for me.

Share:
26,333
Hom nom nom nom ...
Author by

Hom nom nom nom ...

Updated on July 17, 2022

Comments

  • Hom nom nom nom ...
    Hom nom nom nom ... almost 2 years

    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.