rimraf is a cross-platform utility for Node.js that implements the Unix rm -rf command to recursively delete files and directories.
The tool solves the problem of safely removing file system entries in a platform-agnostic way. Node.js lacks a built-in recursive deletion function, and naive implementations often fail on Windows due to file locking and permission issues. rimraf handles these platform differences by using native implementations where available and falling back to a move-then-remove strategy on Windows when exponential backoff for busy file errors fails to resolve the situation. On POSIX systems, the implementation is simplified since the Windows-specific affordances are unnecessary.
Developers should use rimraf when they need reliable recursive deletion in build scripts, cleanup operations, or any Node.js application that must work across operating systems. The tool accepts either a single path or an array of paths, and removal functions return a boolean indicating whether all entries were successfully deleted. A filter option allows selective removal of entries. The tool is suitable for any project that requires cross-platform file system cleanup, though users must never pass untrusted input to it, as the tool is designed to aggressively and recursively remove all items it can find under a given target.
The project maintains active development with regular updates to support current Node.js versions. The codebase is written in TypeScript, providing type safety for users. The tool has undergone significant API evolution, moving from callback-based functions to Promise-based ones and simplifying the module structure to require direct imports of specific functions rather than relying on default exports. Recent versions have introduced platform-specific optimizations, including a native implementation preference on non-Windows systems and improved Windows handling strategies. The project tracks return values as booleans to indicate removal success, providing clearer feedback to callers about operation outcomes.