rm -rf for Node.js, cross-platform
open sourceBlueOak-1.0.0free
rimraf is the Unix rm -rf command for Node.js in a cross-platform implementation: a library (async with promises, sync, and native variants) and a command-line tool that delete files and directories recursively. On Windows it retries with exponential backoff on EBUSY, EMFILE and ENFILE errors and falls back to a move-then-remove strategy, and it supports glob patterns (with the glob option), an AbortSignal to cancel, and protection against deleting the filesystem root. Its README warns never to pass it untrusted input.
Problems it solves
- delete a directory recursively in an npm script on Windows and macOS alike
- remove a build folder from Node.js without shelling out to rm -rf
- clean up files that Windows reports as busy when deleting from Node
- delete files matching a glob pattern from a Node script
Features
- async, sync and native APIs
- CLI for npm scripts
- Windows retries with backoff and move-then-remove fallback
- glob patterns
- AbortSignal support
- root deletion protection
Limitations
- Deletes recursively by design: never pass it untrusted input, and security reports that rely on untrusted input are rejected1
Capabilities
| Has a command line tool | plan not known |
|---|
