talira

Chokidar

Cross-platform file watching library for Node.js

open sourceMITfree

Chokidar is a small, efficient file watching library for Node.js that smooths over the problems of the raw fs.watch and fs.watchFile APIs. It reports proper add, change and unlink events for files and directories, deduplicated and with paths on every platform, uses native fs.watch by default to keep CPU use down, and falls back to stat-based polling for network and other unusual filesystems. It watches recursively everywhere, with an optional depth limit, path filtering and symlink support, and handles editors' atomic writes and large files written in chunks. It was made for the Brunch build tool in 2012.

Problems it solves

  • watch a folder in my Node app and rebuild when a file changes, the same on macOS, Linux and Windows
  • fs.watch fires twice and reports renames instead of changes
  • reload my dev server when files change on a network drive

Features

  • add, change, unlink, addDir and unlinkDir events, verified and deduplicated
  • native fs.watch by default, stat polling for network filesystems
  • recursive watching with depth limits, path filters and symlinks
  • handles atomic writes and chunked writes of large files

Alternatives

The same job

These do what Chokidar does.

  1. Watchman A file watching service that records changes and triggers actions

Compare Chokidar with the top 3