📂
File System30M+/wkISC

rimraf

rimraf is a Node.js implementation of the Unix rm -rf command, providing cross-platform recursive directory and file deletion. The package handles the complexit

Installation

npm
npm install rimraf
yarn
yarn add rimraf
pnpm
pnpm add rimraf

Import

ESM
import { rimraf } from 'rimraf';

Quick Example

usage
import { rimraf } from 'rimraf';

await rimraf('dist');
await rimraf(['tmp', 'cache', '.parcel-cache']);

// In package.json scripts:
// "clean": "rimraf dist node_modules/.cache"

About rimraf

rimraf is a Node.js implementation of the Unix rm -rf command, providing cross-platform recursive directory and file deletion. The package handles the complexities of deleting directory trees on different operating systems — particularly Windows, where files can be locked by other processes, paths can exceed MAX_PATH limits, and junction points need special handling. rimraf retries failed deletions with configurable backoff for handling temporary file locks, supports glob patterns for selecting files to delete, and provides both sync and async APIs. Version 5+ of rimraf uses Node.js's native fs.rm with recursive option when available, falling back to manual traversal for older Node.js versions. The package also provides a CLI interface (npx rimraf dist node_modules) for use in npm scripts. rimraf is one of the most commonly used packages in the npm ecosystem, appearing in thousands of projects' clean and prebuild scripts for removing build output directories, cache directories, and node_modules. The name stands for 'remove recursively, I'm forced' or simply references the rm -rf Unix command. While Node.js 14.14+ includes fs.rm with recursive support, rimraf's Windows handling and retry logic make it more reliable for cross-platform use.

Quick Facts

Packagerimraf
CategoryFile System
Weekly Downloads30M+
LicenseISC
Installnpm install rimraf

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.