Chokidar CLI is an ultra-fast, cross-platform command-line utility designed to watch file system changes and execute arbitrary commands or stream event output. It is built upon the robust and widely adopted `chokidar` library, which is known for its battle-tested stability and efficient file watching across various operating systems, handling quirks of `fs.watch` and `fs.watchFile` by normalizing events and supporting atomic/chunked writes. Currently at version 3.0.0, this tool provides a simple interface for developers to integrate automated tasks, such as compilation or testing, directly into their workflow upon file modifications. While the underlying `chokidar` library has seen recent updates (v4 and v5 as of late 2024/2025), `chokidar-cli` itself has not had a major release since v3.0.0 in July 2021, suggesting a slower release cadence for the CLI wrapper. Its key differentiators lie in abstracting the complexities of file system event handling and providing a straightforward command-line interface for common automation needs without requiring programmatic setup.
npm install chokidar-cliVerified import paths — ran on the pinned version, not inferred.
Demonstrates global installation, watching a glob pattern for `.js` files, and executing a command with event and path details on changes.
Always use double quotes (e.g., `"**/*.js" -c "your command here"`) for patterns and commands. For commands within `package.json` scripts, escape inner double quotes: `"chokidar \"**/*.js\" -c \"echo {event}\"`.After installation (`npm install -g chokidar-cli` or `npm install chokidar-cli`), always use the command `chokidar` to run the utility.
Append `--polling` to your `chokidar` command when watching network-mounted directories: `chokidar "**/*.less" -c "npm run build-less" --polling`.
Monitor `chokidar-cli` release notes for updates regarding its internal `chokidar` dependency. For `chokidar` itself, ensure Node.js v20+ for v5, or v14+ for v4.
Use `chokidar` instead of `chokidar-cli` in your terminal or scripts. Example: `chokidar "./**/*.js" -c "echo File changed"`.
Increase your system's file descriptor limit (e.g., `ulimit -n 2048` on Linux/macOS for the current session, or modify system configuration for permanent changes). Alternatively, refine your glob patterns to watch fewer files and directories, or use `chokidar`'s `ignored` option to exclude unnecessary paths.
Ensure the command passed to `-c` is enclosed in double quotes. If the command itself contains double quotes (e.g., for string literals), escape them properly. Example for `package.json`: `"watch:build": "chokidar \"src/**/*.ts\" -c \"npm run compile -- --path={path}\""`.