Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Cross-Platform
  3. rimraf

rimraf

BlueOak-1.0.0TypeScript

A cross-platform Node.js implementation of the Unix `rm -rf` command for recursively deleting files and directories.

GitHubGitHub
5.8k stars266 forks0 contributors

What is rimraf?

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.

Target Audience

Node.js developers and DevOps engineers who need to programmatically delete files and directories, particularly in build scripts, cleanup tasks, or cross-platform applications.

Value Proposition

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.

Overview

A rm -rf util for nodejs

Use Cases

Best For

  • Cleaning up build artifacts and temporary directories in Node.js projects
  • Writing cross-platform scripts that require recursive file deletion
  • Safely removing nested node_modules directories
  • Implementing file system cleanup in CI/CD pipelines
  • Handling Windows file locking and permission issues during deletion
  • Using glob patterns to selectively delete files in a directory tree

Not Ideal For

  • Projects in non-Node.js environments (e.g., Python or shell-only scripts) where native OS commands are sufficient
  • Real-time applications requiring instantaneous file deletion, as rimraf's retry and backoff mechanisms can introduce latency
  • Interactive file managers or GUI tools needing undo functionality or granular user feedback during deletions

Pros & Cons

Pros

Cross-Platform Reliability

Handles Windows-specific quirks like file locking and permissions with fallback strategies (e.g., move-remove), ensuring consistent deletion across macOS, Linux, and Windows.

Multiple Deletion Strategies

Offers native, manual, Windows-specific, and move-remove implementations, allowing optimization for performance or reliability based on platform and Node.js version.

Flexible API Features

Includes async/sync functions, glob pattern support, filtering, and abort signals, as shown in the options for granular control over deletion logic.

Safety and CLI Utility

Provides options like preserveRoot to prevent accidental root deletion and a CLI with verbose/interactive modes for easy integration into build scripts.

Cons

Security Risks with Input

The README explicitly warns that untrusted input can compromise systems, and security reports based on this are rejected, placing full responsibility on the user.

Performance Overheads

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.

Implementation Complexity

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.

Frequently Asked Questions

Quick Stats

Stars5,842
Forks266
Contributors0
Open Issues7
Last commit24 days ago
CreatedSince 2011

Tags

#devops#cli-tool#nodejs#windows-support#cross-platform#file-system#build-tool

Built With

N
Node.js

Included in

Micro npm Packages4.6kCross-Platform1.2knpm scripts742
Auto-fetched 1 day ago

Related Projects

chokidarchokidar

Minimal and efficient cross-platform file watching library

Stars12,131
Forks626
Last commit27 days ago
fs-extrafs-extra

Node.js: extra methods for the fs object like copy(), remove(), mkdirs()

Stars9,613
Forks783
Last commit10 days ago
cross-envcross-env

🔀 Cross platform setting of environment scripts

Stars6,525
Forks263
Last commit6 months ago
graceful-fsgraceful-fs

fs with incremental backoff on EMFILE

Stars1,301
Forks150
Last commit7 months ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub