📂
File System30M+/wkMIT

chokidar

Chokidar is a fast, efficient file watching library for Node.js that provides a reliable cross-platform API for monitoring file system changes. Node.js's built-

Installation

npm
npm install chokidar
yarn
yarn add chokidar
pnpm
pnpm add chokidar

Import

ESM
import chokidar from 'chokidar';

Quick Example

usage
import chokidar from 'chokidar';

const watcher = chokidar.watch('src/**/*.ts', {
  ignored: /node_modules/,
  persistent: true,
});

watcher
  .on('add', (path) => console.log(`Added: ${path}`))
  .on('change', (path) => console.log(`Changed: ${path}`))
  .on('unlink', (path) => console.log(`Removed: ${path}`));

About chokidar

Chokidar is a fast, efficient file watching library for Node.js that provides a reliable cross-platform API for monitoring file system changes. Node.js's built-in fs.watch has well-known issues including inconsistent behavior across operating systems, not reporting filenames on macOS, emitting duplicate events, not supporting recursive watching on all platforms, and missing events entirely in some scenarios. Chokidar solves these problems by using a combination of native file watching (FSEvents on macOS, inotify on Linux, ReadDirectoryChanges on Windows) with intelligent fallbacks and polling. The library detects file additions, modifications, deletions, directory additions and removals, and provides a clean event-based API: watcher.on('add', path => ...).on('change', path => ...).on('unlink', path => ...). Chokidar supports glob patterns for watched paths, ignored patterns for excluding files, atomic writes detection, and configurable polling intervals for network filesystems. The library is the file watching engine used by webpack, Vite, Rollup, nodemon, Parcel, Karma, and many other development tools. Chokidar handles the complexity of cross-platform file watching so that tools can focus on responding to changes rather than detecting them.

Quick Facts

Packagechokidar
CategoryFile System
Weekly Downloads30M+
LicenseMIT
Installnpm install chokidar

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.