Recently, I've started using Nodemon to auto-refresh my Node js server on changes in files (it's soooo convenient: previously, I used to stop it manually with sigint and restart the project in the command line again). What I did is installed Nodemon on my PC globally (npm install nodemon -g), and now I start my project with the command nodemon app.js (instead of usual node app.js), and everything seems to be great ... except for one thing that pretty annoys me: the server keeps restarting also on changes in my frontend files which are made static in Express by the command app.use(express.static('frontend')) – which is purposeless, because I don't need to restart the Node js server to apply changes in such files (simply to reload a page in a browser is enough). So, is there a way to "learn" nodemon to ignore static frontend files and not to restart the server on changes in them?
Asked
Active
Viewed 497 times
0
-
1you can use `nodemon` with the `--ignore` flag passing the folder containing your static files. For instance `nodemon --ignore assets/*` – sandmann Jan 15 '21 at 19:30
-
1your question can be answered here: https://stackoverflow.com/questions/24120004/nodemon-exclusion-of-files – sandmann Jan 15 '21 at 19:33
1 Answers
1
The issue has been solved by installing nodemon locally + adding to package.json the following code (as offered here):
"scripts": {
"start": "nodemon app.js"
},
"nodemonConfig": {
"ignore": [
"frontend/*"
]
}
Now, if I launch the project either with nodemon app.js, or with npm start, changes in all the files within the frontend folder are ignored.

Roman Karagodin
- 740
- 2
- 11
- 16