Balancing rapid file changes with Nodemon --watch and --delay
Tune Nodemon's watch and delay settings to stop rapid restarts, keep feedback fast, and avoid CPU overload in large projects.
21 Sept 2026, 07:59 UTC

When you edit a source file and Nodemon restarts the Node process every few milliseconds, the constant interruptions break concentration and slow down development.
Why the restart flood happens
Nodemon monitors the filesystem for changes and triggers a process restart. If many files are updated in quick succession—such as when a build step rewrites several files—the watcher may fire multiple restarts, creating a “churn” effect.
Adding a delay with --delay
The --delay flag inserts a pause before each restart. By default it is 0ms, meaning the restart occurs immediately after the event is detected. Supplying a value like 500 adds a half-second pause, giving the system time to finish the current change batch.
- Typical values:
0(no delay),200,500,1000. - Higher values improve stability but can make feedback feel sluggish.
Targeting the right paths
Watching too many directories causes unnecessary events. You can limit the watch list to the folders that actually affect your runtime, for example src and tests, or use glob patterns such as src/**/*.js.
- Run
nodemon --watch src --watch tests --delay 500 app.jsin your project root. - Modify a file inside
src/; Nodemon waits 0.5 s, then restartsapp.js. - Modify a file inside
tests/; the same delay applies.
Persisting the configuration
Instead of repeating long flags, create a nodemon.json file in the project root:
{
"watch": ["src", "tests"],
"delay": 500,
"exec": "node"
}
Running nodemon app.js will now apply those settings automatically.
Verifying the setup
To confirm the delay works, open a terminal, start Nodemon with the command above, then edit a file in src/. Observe that the process restarts only after the specified pause. You can also enable verbose logging:
nodemon --verbose app.js
The log will show watch paths and the debounce interval, letting you verify that the delay is respected.
Trade-offs and limitations
- Longer delays reduce the immediacy of feedback, which can slow bug hunting.
- Watching a large number of paths increases CPU usage and may cause missed events, especially on Windows where file-system notifications are less reliable.
- Custom
--execcommands must be quoted correctly; improper quoting can prevent environment variables from being passed to the child process. - Nodemon is intended for development only; using it in production is not recommended.
Actionable closing
Start by adding a modest delay (e.g., 500 ms) and narrowing the watch list to the directories that influence your runtime. Verify the behavior with a quick file edit, then adjust the delay up or down until the restart cadence matches your preferred feedback speed. This simple tuning lets you keep rapid iteration without the distraction of constant restarts.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.