Nodemon - specifying extension watch list using config files
Asked Answered
E

3

9

Is there a way to specify watch list using config files instead of command line?


Command line method in nodemon's doc:

nodemon github


I attempted to use a nodemon.json config file with the following:

{ 
"ext": ["js", "json", "hbs", "html"]
}

Returned an 'extension.match' error.

Then I tried to add the config to package.json with the below:

{...
"nodemonConfig": {
    "ext": ["js", "json", "hbs", "html"]
  }
...}

Also same error.

I have a feeling both approaches are on the right track, but I'm missing something.

Empower answered 9/4, 2021 at 11:7 Comment(0)
E
16

You can use a nodemon.json file in the root of your application you were almost there but the syntax is slightly different to what you had the correct syntax would look like this:

{
    "ext": "js,json,hbs,html"
}
Ecstatics answered 9/4, 2021 at 11:41 Comment(1)
Thanks, it works. Nodemon ext matches a string rather than an array.Empower
D
8

Nodemon also supports using package.json for configuration, under nodemonConfig key.

The config is in the same format as in the nodemon.json config file:

package.json

{
  ...
  "nodemonConfig": {
    "ext": "js,json,hbs,html",
    ...
  }
}
Doughman answered 28/4, 2022 at 7:27 Comment(0)
P
3

Step 1: First you add nodemon.json file in the root of your project. (For example if you have a Weather-App Project first you add nodemon.json in the root.)

      Weather-App _
                   |_ nodemon.json

Step 2: Add this code in newly created nodemon.json file.

        {
          "ext": "js,json,hbs,html,css"
        }   
Pumpernickel answered 1/4, 2022 at 22:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.