rimraf
Cross-platform recursive file and directory removal for Node.js, modeled on the UNIX `rm -rf` command.
Repository Health
Technical Analysis
rimraf is a small, battle-tested Node.js module that recursively deletes files and directories, providing a reliable cross-platform equivalent to the UNIX rm -rf command. It ships both a programmatic API (rimraf, rimrafSync, and platform-specific strategies like native, windows, and moveRemove) and a CLI binary, and automatically selects the fastest safe implementation for the current Node.js version and operating system.
Because deleting files reliably across Windows, macOS, and Linux involves subtle edge cases (locked files, EBUSY/EPERM errors, non-atomic unlink/rmdir calls), rimraf has become a de-facto standard dependency in build tools, test harnesses, and CLI utilities that need to clean up directories without reinventing platform-specific retry and fallback logic.
What You Get
- Async and sync APIs (
rimraf,rimrafSync) that resolve to a boolean success value - Multiple removal strategies (
native,windows,manual,posix,moveRemove) selectable per platform or forced explicitly - A CLI binary supporting glob patterns, verbose output, interactive confirmation, and configurable retry/backoff
- An
AbortSignal-aware API for cancelling long-running directory removals - A
filteroption to selectively exclude paths from deletion while still recursing into their children
Common Use Cases
- Cleaning build output directories (
dist/,build/) before a fresh compile - Removing temporary test fixtures and scratch directories between test runs
- Deleting
node_modulesor cache directories as part of a reset/clean npm script - Deleting arbitrary glob-matched paths from a CLI or CI pipeline step
Under The Hood
Architecture rimraf is organized around a shared wrap/wrapSync higher-order function (src/index.ts) that normalizes single-path and array-of-paths inputs, resolves glob patterns via the glob package, and dispatches to one of five interchangeable removal strategies (native, posix, windows, manual, moveRemove), each implemented in its own module (rimraf-native.ts, rimraf-posix.ts, rimraf-windows.ts, rimraf-manual.ts, rimraf-move-remove.ts). use-native.ts decides at call time whether the built-in fs.rm can be used, falling back to the JS-implemented Windows/POSIX strategies when a filter or signal option is supplied, since Node’s native implementation doesn’t support those.
Tech Stack The project is TypeScript-first, built with tshy to emit dual ESM/CommonJS output, targets Node 20 or >=22, and depends on only two runtime packages (glob and package-json-from-dist). Testing uses tap with recorded snapshots in tap-snapshots/, linting uses oxlint, and docs are generated via typedoc.
Code Quality The test/ directory mirrors src/ one-to-one (17 files) plus an integration/ suite, with dedicated coverage for edge cases like EPERM handling (fix-eperm.ts) and ENOENT-safe readdir (ignore-enoent.ts). Modules are small and single-purpose, options parsing/validation is centralized in opt-arg.ts rather than duplicated per-strategy, and the codebase carries no any-typed escape hatches in the reviewed entry points.
API Design The public surface is intentionally narrow: rimraf/rimrafSync cover the common case, with named exports (native, windows, manual, posix, moveRemove) available for callers who need to force a specific strategy. All removal functions return a plain boolean rather than throwing on partial removal, and the CLI mirrors the same option set (--glob, --impl, --preserve-root), keeping the library and CLI mental models consistent.
Used by 87 apps in this directory
NocoDB
Databases · Low Code Platforms · No Code Platforms
Turn any SQL database into a collaborative no-code spreadsheet with automatic REST APIs and real-time views.
NodeBB
Community
Modern Node.js forum software with real-time WebSockets, multi-database support, and a plugin ecosystem — the community platform built for the open web and the Fediverse.
Novu
Developer Tools
Open-source communication infrastructure that connects your products and AI agents to every channel your users live on — Inbox, Email, SMS, Push, Chat, and more.
OnetimeSecret
Security
Generate self-destructing single-use links to share passwords and sensitive data without leaving traces in inboxes or chat logs.
OpenPanel
Devops · Hosting Control Panel
Docker-powered web hosting control panel that gives every user a fully isolated environment with dedicated web server, database, and networking — VPS-grade security on shared hardware.
Outline
Collaboration · Knowledge Management
A fast, real-time collaborative knowledge base for growing teams built on React, Node.js, and ProseMirror.
Payload CMS
Blogging · CMS · Developer Tools
The open-source, Next.js-native headless CMS that lives inside your /app folder and gives you a full TypeScript backend instantly.
Penpot
Design Tools
Open-source design platform with GPU-accelerated canvas, native design tokens, and MCP-powered AI workflows for teams that ship fast.
Arize Phoenix
Analytics · Devops · Monitoring
Open-source AI observability platform for tracing, evaluating, and debugging LLM applications with built-in intelligence and MCP support.