Nodemon Keeps Restarting Server
Solution 1:
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).
Solution 2:
Solution 3:
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"}
Solution 4:
I was puzzled by a constant stream of restarts. I started with nodemon --verbose
to see what was causing the restarts.
This revealed that my package.json file was the culprit. I was running my installation in a Dropbbox folder and had just removed all files from my node_modules folder and done a fresh install. Another computer that shared my Dropbox folder was running at the time, and unknown to me, it was busily updating its node_module files and updating the Dropbox copy of package.json files as it did so.
My solution turned out to be simple, I took a break and waited for Dropbox to finish indexing the node_modules folder. When Dropbox finished synching, nodemon ran without any unexpected restarts.
Solution 5:
In my case (which is the same as the OP) just ignoring the database file worked
nodemon --ignore server/db.json server/server.js
Post a Comment for "Nodemon Keeps Restarting Server"