Nodemon Ignore Lists: Stopping Restart Loops in Node.js Development
Unwanted nodemon restarts often come from watching generated files. Using nodemon.json to define extensions and ignore patterns makes watch boundaries explicit and prevents restart loops in Node.js development.
06 Dec 2025, 14:05 UTC

You save a route file, nodemon restarts the server, and a second restart fires immediately because your app just wrote to a log file in a watched directory. That loop is not a bug in your code. It is a boundary problem: nodemon watches files, and by default the boundary is too wide.
The useful takeaway is to treat nodemon configuration as an engineering decision about what counts as source versus artifact, not as a convenience toggle.
Where unwanted restarts come from
Nodemon monitors a directory tree and restarts the Node.js process when it detects changes. The watcher uses file system events, so any write inside the watched tree can trigger a restart.
In development this is desirable for .js, .json, and template files. It is undesirable for generated files, logs, coverage reports, or build output that your application itself creates. When those files are watched, a restart can cause the app to write again, which triggers another restart.
Making watch boundaries explicit
A nodemon.json file makes the watch set explicit and versionable. It lets you declare extensions to monitor and paths to ignore.
// nodemon.json
{
"watch": ["src"],
"ext": "js,json,html",
"ignore": [
"src/**/*.log",
"src/tmp/*",
"node_modules",
"coverage/*"
]
}Place this file in the project root. The watch array narrows the root to src. The ext list limits events to specific extensions. The ignore array prevents restarts when log or temporary files change.
Run nodemon from the project root with no elevated permissions required:
npm install --save-dev nodemon
npx nodemon src/server.jsCheck the result by editing a file matching the ext list and confirming the process restarts, then editing a file matching an ignore pattern and confirming no restart occurs. The terminal output is expected to include a restarting message when a watched file changes.
Standardizing the dev start
Embedding nodemon in package.json scripts removes ambiguity about how the team starts the dev server.
// package.json
{
"scripts": {
"dev": "nodemon src/server.js"
}
}With this, the command to run locally is npm run dev from the project root. The same nodemon.json applies to all contributors, which reduces drift between environments.
Trade-offs and limits
Nodemon is for development only. Using it in production can cause instability and resource leaks because restarts are not coordinated with load balancers or graceful shutdown.
Watching very large trees can increase CPU usage and hit OS limits such as too many open files. Narrowing watch with explicit paths and ignore patterns mitigates this.
Configuration errors in ignore can hide real changes. If you ignore too broadly, edits to source files will not trigger restarts and you will need to restart manually.
The --signal flag allows sending a specific signal like SIGUSR2 instead of the default SIGTERM during restarts. This is useful when your app handles graceful shutdown, but the signal must be implemented by the application to be effective.
Verify your setup after changes: start the dev server, modify a watched source file, and confirm a restart. Then modify an ignored file and confirm no restart. Adjust ignore patterns if restart loops reappear.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.