nodemon ignore directory
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?
Solution 1:
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
Solution 2:
In the very likely circumstance that you're using nodemon
in a configuration file, you can create a separate configuration entry for those files to be ignored. Bonus, a cleaner looking nodemon
call, especially if files to ignore grows large.
For example, this package.json
instructs nodemon
to ignore directory test
:
{
"scripts": {
"test": "jest",
"start": "nodemon server.js"
},
"nodemonConfig": {
"ignore": ["test/*"]
}
}
Find the complete instructions for nodemon configuration file settings here.
As in the other answer, be sure to restart nodemon
for the configuration changes to take effect.