Chokidar
Efficient cross-platform filesystem watcher that normalizes native events and supports glob filtering.
Official Documentation ↗v6.0.0. Check the official docs for the latest API surface.Installation
npm install chokidarMethods
No methods match this filter.
Chokidar wraps fsevents, inotify, and kqueue behind one stable API that emits add, change, and unlink events.
Key Features
- Recursive watching on every major platform
- Debounced write detection to consolidate bursts
- Glob and function based ignore filtering
Usage Notes
Pin a version and check the official docs for the API surface you depend on before upgrading.
Errors
The following points are quoted verbatim from the official documentation. 来源:https://cdn.jsdelivr.net/gh/paulmillr/chokidar@latest/README.md · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:48:48.041Z. Any error type, throw condition or recovery step not stated there is left unspecified; this page does not infer exception classes or return values.
- Errors and lifecycle - ignorePermissionErrors (default: false). (https://cdn.jsdelivr.net/gh/paulmillr/chokidar@latest/README.md)
- When true, EPERM / EACCES errors from unreadable paths are suppressed instead of emitted. (https://cdn.jsdelivr.net/gh/paulmillr/chokidar@latest/README.md)
- Repeated calls return the same Promise; once closing has started, .add() throws and a new FSWatcher is required. (https://cdn.jsdelivr.net/gh/paulmillr/chokidar@latest/README.md)
FAQ
- Why do I get duplicate change events?
- Editors write via atomic rename, producing unlink plus add. Keep atomic: true and use awaitWriteFinish to consolidate rapid write bursts.
- Does chokidar handle recursive watching on Linux?
- Yes since v3, but very large trees can exhaust the inotify watcher limit. Raise fs.inotify.max_user_watches or watch only needed subdirectories.
- What is the difference between ignore and ignored?
- Use ignored to exclude paths from events, and ignoreInitial: true to suppress add events for files already present when watching starts.
Report a problem with this API docOpens a pre-filled issue on GitHub.