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?
You can use ls 'your exlusions' && nodemon app. js (not cross platform). If you are willing to write code for it, you can listen to nodemon 'start' or 'restart' event and print excluded files by reading nodemon config and expanding glob patterns in "ignore" array.
Note that by default, nodemon will ignore the . git and node_modules/**/node_modules directories.
Nodemon is a utility depended on about 3 million projects, that will monitor for any changes in your source and automatically restart your server. Perfect for development. Swap nodemon instead of node to run your code, and now your process will automatically restart when your code changes.
Press Ctrl + C to exit from Nodemon on windows.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With