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:That means, when you run
npm start
, the commandnodemon
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 asnodemon ./bin/www
, which will not ignore the files you want ignored.Make the change to your
package.json
and only usenpm start
. Do not typenodemon
directly into the command line, there is no need.