A cross-platform Node.js implementation of the Unix `rm -rf` command for recursively deleting files and directories.
Rimraf is a Node.js package that provides a cross-platform implementation of the Unix `rm -rf` command for recursively deleting files and directories. It solves the problem of safely and reliably removing nested file structures in Node.js applications, especially on Windows where native operations can be problematic. The tool includes multiple deletion strategies and a command-line interface for use in scripts and build processes.
Node.js developers and DevOps engineers who need to programmatically delete files and directories, particularly in build scripts, cleanup tasks, or cross-platform applications.
Developers choose Rimraf for its reliability across platforms, especially on Windows, and its flexible API with support for globs, filtering, and multiple deletion strategies. It is a trusted, battle-tested utility that handles edge cases better than naive implementations.
A rm -rf util for nodejs
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Handles Windows-specific quirks like file locking and permissions with fallback strategies (e.g., move-remove), ensuring consistent deletion across macOS, Linux, and Windows.
Offers native, manual, Windows-specific, and move-remove implementations, allowing optimization for performance or reliability based on platform and Node.js version.
Includes async/sync functions, glob pattern support, filtering, and abort signals, as shown in the options for granular control over deletion logic.
Provides options like preserveRoot to prevent accidental root deletion and a CLI with verbose/interactive modes for easy integration into build scripts.
The README explicitly warns that untrusted input can compromise systems, and security reports based on this are rejected, placing full responsibility on the user.
Synchronous operations are slower than async, and retry mechanisms with exponential backoff can delay deletions in busy file systems, as noted in the maxRetries and backoff options.
Multiple implementations (e.g., native, manual, windows) require users to understand platform nuances, and features like filter or signal disable the faster native fs.rm.