Nodemon: How can I watch multiple directories?

Created on 28 Jul 2017  ·  9Comments  ·  Source: remy/nodemon

I need something like this:

[{
  "watch": ["src/api-gateway"],
  "ext": "ts",
  "ignore": ["src/**/*.spec.ts"],
  "exec": "ts-node ./src/api-gateway/main.ts"
},
{
  "watch": ["src/services/ping-service"],
  "ext": "ts",
  "ignore": ["src/**/*.spec.ts"],
  "exec": "ts-node ./src/services/ping-service/ping-service.ts"  
}]

Is that possible?

needs latest nodemon

Most helpful comment

Hello,

Sorry to bring this back, but I'm having some issues with specific watched directories in an express app.

From the docs I have this:

nodemon --watch app --watch libs app/server.js

When I try to run this code nothing happens when something changes in any of the directories being watched:

nodemon --watch build --watch public build/server.js

Basically I want to restart the server whenever there's a change in the server or client code. The server does start but never restarts automatically when a change happens and the bundling process is working fine.

If I run the code without the watch flags, nodemon looks for changes in all the folders and it does works. What I want is to keep track only of those two folders.

All 9 comments

I think if you run nodemon from from a parent directory where you have your file that starts the server it watches changes to all the files in sub directories.
or you could try watch: "src/." and combine all that into one object, samething for the exec prop. Not really sure though.

@vforv deal with it?

Hello,

Sorry to bring this back, but I'm having some issues with specific watched directories in an express app.

From the docs I have this:

nodemon --watch app --watch libs app/server.js

When I try to run this code nothing happens when something changes in any of the directories being watched:

nodemon --watch build --watch public build/server.js

Basically I want to restart the server whenever there's a change in the server or client code. The server does start but never restarts automatically when a change happens and the bundling process is working fine.

If I run the code without the watch flags, nodemon looks for changes in all the folders and it does works. What I want is to keep track only of those two folders.

@rhernandog have you tried out all the solutions above?

@rhernandog can you give this a test with latest [email protected]? I think I found this in the code and fixed it (not sure how it broke, but I was able to replicate the issue with a single dir and then this latest build fixes it).

@remy Thanks I'll update the package and let you know how it went.

@rhernandog can you test with [email protected]? I've pushed a change that fixes (some) directory watching problems.

This is working in the latest release. Please go ahead and upgrade ❤️

@remy Sorry I couldn't get back before.

Is working great with the latest update, thanks for the great work!!! :clap::clap:

Was this page helpful?
0 / 5 - 0 ratings