Controlling Nodemon Restarts with the ignore Feature
Learn how to use nodemon’s ignore feature to prevent unwanted restarts caused by temporary or log files, with a concrete example, configuration details, and verification steps.
28 Sept 2026, 18:37 UTC

The problem: unwanted restarts
When developing a Node.js application, nodemon is handy for automatically restarting the server whenever source files change. However, it also watches every file under the project directory by default. If you frequently edit logs, temporary files, or generated assets, each change triggers a restart, slowing down your workflow and cluttering the terminal.
Thesis: use nodemon’s ignore to filter out noise
Nodemon provides an --ignore option (or an ignore array in nodemon.json) that accepts glob patterns. Files matching any of those patterns are excluded from the watcher, so changes to them no longer cause a restart. The ignore logic is applied after the default watch set and uses the micromatch library, supporting full glob syntax such as **, *, ?, character classes, and brace expansion.
How to configure ignore patterns
You can set ignores either on the command line or in a configuration file.
- CLI:
nodemon --ignore "tmp/**" --ignore "*.log" src/index.js - Configuration file (nodemon.json):
{
"ignore": ["tmp/**", "*.log"],
"exec": "node src/index.js"
}
Place nodemon.json in the project root. When nodemon starts, it reads this file and treats the listed patterns as ignored.
Worked example: ignoring a temporary directory
- Create a test layout:
my-project/
├── src/
│ └── index.js
├── tmp/
│ └── scratch.txt
└── nodemon.json
- Add the following to
nodemon.json:
{
"ignore": ["tmp/**"],
"exec": "node src/index.js"
}
- Run nodemon from the project root (you need read/execute permission on the folder):
nodemon
Nodemon will start src/index.js and begin watching.
- Edit
tmp/scratch.txt(e.g., add a line). Observe the terminal: no restart message appears. - Edit
src/index.js(e.g., change a console.log). Observe: nodemon prints a restart signal and reloads the application.
To verify that the ignore pattern is being applied, start nodemon with the debug flag:
nodemon --debug
In the debug output you will see a section like:
Ignored: tmp/**
Watched: src/**
This confirms that files under tmp/ are excluded from the watcher.
Limitations and practical checks
- Overly broad patterns: Using
"**"as an ignore will silence all file changes, leaving nodemon unresponsive to legitimate code updates. Test by temporarily adding such a pattern and verifying that editing source files no longer triggers a restart. - Symlinked files: If a symlink points to a file outside the watched tree, the ignore pattern is evaluated against the symlink path, not the target. To ignore the target, add a pattern that matches the real path or avoid symlinking files you want to watch.
- Version consistency: The ignore behavior relies on micromatch, which was introduced in nodemon 2.0. Older 1.x releases use a different glob implementation and may not support advanced patterns like brace expansion. If you need to support both, keep patterns simple (e.g.,
tmp/**) or test withnodemon --debugon each version.
Practical way to check your ignore list: after nodemon starts, run nodemon --debug in a separate terminal session (or restart with the flag) and look for the “Ignored:” lines. Adjust patterns until only the intended directories appear there.
Actionable closing
If your development loop is slowed by unnecessary restarts, audit the files you edit most often that aren’t source code. Add precise glob patterns to nodemon.json (or the CLI) to exclude them. Validate the change with nodemon --debug and a quick edit test. Keep patterns as specific as possible to avoid accidentally silencing important updates, and revisit the ignore list whenever you add new generated directories or log files. This small tweak can restore the fast, responsive feedback loop nodemon is meant to provide.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.