whatisgithub

What is rimraf?

isaacs/rimraf — explained in plain English

Analysis updated 2026-06-26

5,841TypeScriptAudience · developerComplexity · 1/5Setup · easy

In one sentence

A Node.js utility that deletes entire folders in one call, cross-platform, the JavaScript equivalent of `rm -rf`, with built-in retries to handle Windows file-locking issues.

Mindmap

mindmap
  root((rimraf))
    What it does
      Delete folders recursively
      Cross-platform rm -rf
      Handle Windows locks
    API
      Promise-based async
      Synchronous version
      Glob pattern filter
      AbortSignal support
    Tech Stack
      TypeScript
      Node.js 20+
      npm
    Use Cases
      Build cleanup scripts
      Test teardown
      Deploy prep
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Wipe out a build output folder like `dist/` or `node_modules/` as part of an npm script

USE CASE 2

Clean up temporary directories created during automated tests so the next run starts fresh

USE CASE 3

Delete a folder tree cross-platform in a Node.js script without worrying about Windows file-locking errors

USE CASE 4

Cancel a long folder deletion halfway through using an AbortSignal in an async workflow

What is it built with?

TypeScriptNode.jsnpm

How does it compare?

isaacs/rimrafvanilagy/mediabunnyangular/flex-layout
Stars5,8415,8425,845
LanguageTypeScriptTypeScriptTypeScript
Setup difficultyeasyeasyeasy
Complexity1/52/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

Requires Node.js 20 or 22+, install via npm install rimraf.

No license information was mentioned in the explanation.

So what is it?

Rimraf is a Node.js utility for deleting files and entire folder trees in one operation. It is the cross-platform equivalent of the Unix command rm -rf, which removes everything inside a directory recursively without asking for confirmation. The name comes from that command. It is installed via npm and used in JavaScript projects wherever you need to wipe out a directory as part of a build, cleanup, or deployment script. The library exists because Node.js itself did not always provide a built-in way to delete folders reliably across operating systems. Windows in particular causes problems when deleting files that are still open or locked by another process. Rimraf handles those cases with automatic retries and a fallback strategy that moves files to a temporary location before removing them, which works around Windows file locking issues. The API is straightforward: call rimraf with a path (or a list of paths) and it returns a Promise that resolves when deletion is complete. A synchronous version is also available. Options let you delete only files matching a pattern, skip certain files with a filter function, or cancel the operation partway through using an AbortSignal. The README includes a prominent safety warning: you must never pass input from untrusted users to this function. Because its purpose is permanent deletion, passing the wrong path can destroy important data. The responsibility for what paths are passed to it stays with the developer using it. Version 4 and later default to the built-in Node.js removal API on modern Node versions, falling back to the older JavaScript implementations only when needed. The current version requires Node 20 or 22 and above.

Copy-paste prompts

Prompt 1
I want to add a clean step to my Node.js project that deletes the dist/ and .cache/ folders before each build. Show me how to use rimraf in a package.json script to delete both paths at once.
Prompt 2
Using rimraf in a Node.js script, how do I delete all .log files inside a folder tree without deleting the folder itself? Show the glob pattern and the options object.
Prompt 3
I'm running rimraf on Windows and getting EBUSY errors when trying to delete a folder. How does rimraf handle Windows file locking and what options can I set to make deletion more reliable?
Prompt 4
I want to use rimraf with an AbortSignal so I can cancel the deletion if a timeout fires. Show me the async JavaScript code to set a 5-second timeout and abort the rimraf call if it takes too long.

Frequently asked questions

What is rimraf?

A Node.js utility that deletes entire folders in one call, cross-platform, the JavaScript equivalent of `rm -rf`, with built-in retries to handle Windows file-locking issues.

What language is rimraf written in?

Mainly TypeScript. The stack also includes TypeScript, Node.js, npm.

What license does rimraf use?

No license information was mentioned in the explanation.

How hard is rimraf to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is rimraf for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.