Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Track yaml file changes in nodemon

Nodemon does not reload after yaml files change. How can I configure nodemon to reload the server when a yaml file changes?

like image 917
Rumesh Madhusanka Avatar asked Jan 16 '20 20:01

Rumesh Madhusanka


2 Answers

nodemon can also be configured using a config file.

Create a file named nodemon.json and place it in the root of your project, for example where your project's package.json file already is.

If you want to add .yaml to the default extensons watched, put this code in your nodemon.json

{
  "ext": ".js, .mjs, .coffee, .litcoffee, .json, .yaml"
}
like image 115
Alex Baban Avatar answered Sep 23 '22 22:09

Alex Baban


You can configure nodemon to watch your yaml files in two ways:

  1. By extension
  2. With the file path

By Extension

The documentation states that:

By default, nodemon looks for files with the .js, .mjs, .coffee, .litcoffee, and .json extensions.

You can specify your own list with the -e (or --ext) switch

Like so:

nodemon -e yaml server.js

Note: the dot before the extension .yaml is not mandatory, you can omit it.

Now when any .yaml file changes, your server will restart.


With the file path

You can use the flag -w (or --watch)

The wiki says:

Watch directory "dir" or files. use once for each directory or file to watch.

Like so:

nodemon -w file1.yaml -w file2.yaml server.js

You'll see something like

[nodemon] watching: file1.yaml file2.yaml

Now when one of these two files changes it will restart, but it wont' watch another .yaml file if it is not specified.

like image 37
Mickael B. Avatar answered Sep 20 '22 22:09

Mickael B.