I am using node js and the nodemon module.
Problem: If I change file in front-end the server will be automatically restarted.
Expected: If I change the few js or few files inside the path it should not restart the server.
I tried the following code:
nodemon --ignore 'public/javascripts/template_files/*.js'
But the above code not working. If I change any js files inside the template_files folders means the server restarting again and again.
Based on the comments I now have enough information to explain what's going on.
In your package.json
, your start script needs to look like this:
"scripts" : {
"start" : "nodemon ./bin/www --ignore 'public/javascripts/template_files/*.js'"
},
That means, when you run npm start
, the command nodemon
should be run (monitoring all file changes), executing the ./bin/www
file, but not monitoring those specific JS files. If a file (other than the ignored files) changes, re-execute the ./bin/www
file.
What you were doing before was trying to execute nodemon --ignore 'public/javascripts/template_files/*.js'
from the command line, which won't execute any particular file (IIRC), and also leaving the start script as nodemon ./bin/www
, which will not ignore the files you want ignored.
Make the change to your package.json
and only use npm start
. Do not type nodemon
directly into the command line, there is no need.
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