nodemon ignore directory

softcode picture softcode · Jan 28, 2017 · Viewed 28.4k times · Source

In a Universal Javascript app, I would like nodemon to ignore client directory changes.

I have tried the following:

"devStart": "nodemon server/server.js --ignore 'client/*' --exec babel-node",
"devStart": "nodemon server/server.js --ignore 'client/' --exec babel-node",
"devStart": "nodemon server/server.js --ignore client/ --exec babel-node",
"devStart": "nodemon --ignore 'client/*' server/server.js --exec babel-node",
"devStart": "nodemon --ignore 'client/' server/server.js --exec babel-node",
"devStart": "nodemon --ignore client/ server/server.js --exec babel-node",

None of these work.

File structure:

+-server
+-client
+-package.json <------- where nodemon script is

However this is not working. Pretty sure it is a pattern issue.

Any ideas?

Answer

hackerrdave picture hackerrdave · Jan 28, 2017

You need to replace .. with ., or just reference client/ directly, also you will need to remove the asterisk:

"devStart": "nodemon --ignore './client/' --exec babel-node src/server.js"

Or

"devStart": "nodemon --ignore 'client/' --exec babel-node src/server.js"

According to nodemon docs this is how to ignore a directory via command line:

nodemon --ignore lib/ --ignore tests/

Also note that nodemon will only restart the node process, if you change the npm script you will need to kill the process and re-run npm run devStart