rimraf

Cross-platform `rm -rf` for Node.js. Recursively deletes files and directories on Windows, macOS, and Linux. Handles Windows file locking issues that native rm -rf doesn't. Widely used in build scripts and package.json scripts for cleaning dist/ or build/ directories. v4+ uses native Node.js fs.rm() with rimraf as a reliable cross-platform wrapper.

Evaluated Mar 06, 2026 (0d ago) v5+
Homepage ↗ Repo ↗ Developer Tools nodejs delete rm-rf cross-platform cli filesystem build
⚙ Agent Friendliness
68
/ 100
Can an agent use this?
🔒 Security
96
/ 100
Is it safe for agents?
⚡ Reliability
83
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
88
Error Messages
82
Auth Simplicity
100
Rate Limits
100

🔒 Security

TLS Enforcement
100
Auth Strength
100
Scope Granularity
100
Dep. Hygiene
88
Secret Handling
88

Destructive operation — no confirmation. Path traversal bugs in calling code could delete unintended files. Always validate paths before passing to rimraf.

⚡ Reliability

Uptime/SLA
92
Version Stability
80
Breaking Changes
75
Error Recovery
85
AF Security Reliability

Best When

Writing cross-platform npm scripts or Node.js build tools that need reliable recursive directory deletion.

Avoid When

Targeting modern Node.js 18+ on non-Windows systems — native fs.rm() is sufficient.

Use Cases

  • Clean build output directories (dist/, build/, .next/) in npm scripts cross-platform: "clean": "rimraf dist"
  • Delete temporary directories in Node.js build tools and scripts without platform-specific rm -rf / rmdir /s /q handling
  • Remove node_modules for clean reinstalls: rimraf node_modules && npm install
  • Use programmatic API in build scripts to delete files matching glob patterns cross-platform
  • Handle Windows file locking by retrying deletion with configurable backoff when files are in use

Not For

  • Production application code that deletes user data — rimraf is a build tool; use explicit fs operations with validation for production file deletion
  • Cases where Node.js 14.14+ native fs.rm({recursive: true, force: true}) suffices — rimraf adds value primarily on older Node.js or Windows
  • Fast batch file operations — rimraf has overhead vs native C implementations for large directory trees

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

Build tool — no auth needed.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

ISC licensed open source library.

Agent Metadata

Pagination
none
Idempotent
Full
Retry Guidance
Documented

Known Gotchas

  • rimraf v4/v5 is ESM-first — require('rimraf') may fail in CommonJS projects; use import or the sync export explicitly
  • rimraf v3 to v4 migration: the default export changed from synchronous to async — wrap in await or use rimrafSync for sync behavior
  • Glob patterns in rimraf v4+ use glob package patterns — paths with special characters must be escaped
  • rimraf does not throw for non-existent paths by default — check if deletion actually occurred if your code depends on path existence
  • Windows: rimraf retries on EBUSY errors with backoff — deletion may take longer than expected when files are open in other processes
  • rimraf deletes WITHOUT confirmation or recycle bin — there is no undo; always verify the path before calling rimraf in scripts

Alternatives

Full Evaluation Report

Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for rimraf.

$99

Scores are editorial opinions as of 2026-03-06.

5215
Packages Evaluated
26151
Need Evaluation
173
Need Re-evaluation
Community Powered