Nodemon keeps restarting server

From the documentation:

nodemon will watch the files in the directory in which nodemon was started, and if any files change, nodemon will automatically restart your node application.

If your db's .JSON file is under the watch of nodemon, and you're constantly writing to it, your server will restart in an infinite loop thus making it inaccessible. Try moving your .JSON file outside the scope of nodemon's watch via moving it outside your directory or via some nodemon configuration (if possible).


My solution: I've added nodemonConfig in package.json file in order to stop infinite loop/restarting. In package.json:

"nodemonConfig": { "ext": "js", "ignore": ["*.test.ts", "db/*"], "delay": "2" },
"scripts": { "start": "nodemon" }

I solved this issue from this page.

practically you just have to do

 nodemon --ignore 'logs/*'