Skip to content
Agents tracked: 506 Releases (7d): 634 Agent status: 3 with issuesSince last limit reset: Claude 15d · Codex 0d For AI agents: Markdown Updated Nov 26, 2026

rimraf

Delete folders the same way on every system.

Dev workflow and configNPM

GitHubWebsite

1. License

“Each contributor licenses you to do everything with this software that would otherwise infringe that contributor's copyright in it.”

Blue Oak 1.0.0 allows any use, including paid and closed products.

github.com/isaacs/rimraf/blob/main/LICENSE.md

From the package registry and GitHub, checked daily; card checked Nov 11, 2026. Tap a verdict to see its source.How we checkedReport an error

What rimraf does

rimraf is a small free JavaScript package that deletes files and whole folders, like the rm -rf command, and works the same on Windows, Mac and Linux. Projects use it to wipe build output or caches before a fresh build. What it deletes is gone for good; it does not use the trash.

What people build with it

Wipe the build folder first Idea

Before each build, old files in dist are removed so nothing stale gets shipped. One line in the scripts section of package.json does it.

Same delete command on every computer

Teammates on Windows and on Mac run the same clean script; rm -rf alone would fail on a plain Windows shell.

Delete files by pattern

Remove every .log or .map file under a folder in one call instead of listing each one.

Clear a cache but keep a marker file

Empty a cache folder while keeping the .gitkeep file that keeps the folder in git.

Stop a huge delete on time

A cleanup job deletes a very large folder but must give up after a set time instead of blocking everything.

Remove test leftovers Idea

After a test run, delete the temporary folders the tests created so the next run starts clean.

rimraf popularity

74 / 100
Gid Score, #248 overall
216M
downloads a week, npm
5,859
GitHub stars
161
agent projects use it
rimraf: downloads per weeknpm, rimraf 216,195,801
rimraf: GitHub starsisaacs/rimraf 5,859

Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated

How rimraf is used

  • rimraf is a dependency in 161 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (3.3% of the 4,867 JavaScript/TypeScript ones), #12 of 299 in dev workflow and config.
  • Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 457; those are left out of every share on this page.
  • Projects that use it most often also use TypeScript (88.2%), ESLint (66.5%), Prettier (49.7%).
  • It is more common in projects set up for OpenAI Codex (4.7%) than for OpenCode (1.7%).

By coding agent

88 projects, 2.7%
81 projects, 2.7%
62 projects, 2.5%
22 projects, 4.7%
14 projects, 3.0%
8 projects, 2.9%
6 projects, 1.7%
5 projects, 3.6%

Often used with

In 88.2% of its projects
In 66.5% of its projects
In 49.7% of its projects
In 32.9% of its projects
In 28.0% of its projects
In 42.2% of its projects
In 21.1% of its projects
In 33.5% of its projects

More about rimraf

Funding
  • GitHub Sponsors: https://github.com/isaacs
  • 23 GitHub sponsors

See all

More in Dev workflow and config

Alternatives

rimraf This page

BlueOak-1.0.0Gid 74216M/wk

del

Pick del when you want to delete by glob patterns as the normal way of working, from Node.js code.

shx

Pick shx when your scripts need several shell commands (copy, move, make folders), not just delete.

fs-extra

Pick fs-extra when your code also copies and creates folders and you want one helper package for all of it.

Compare rimraf with another tool

Get started

Tell your AI assistant

“Add rimraf 6.1.4 (Node 20 or 22+) as a dev dependency, use "rimraf dist" in a prebuild script, and in code use import { rimraf } from "rimraf" with await; never pass user input to it.”

  1. Add it to the project.

    npm install rimraf

    From github.com/isaacs/rimraf/blob/main/README.md

  2. Import the function by name and await it with a path or a list of paths.

    import { rimraf, rimrafSync, native, nativeSync } from 'rimraf'

    From github.com/isaacs/rimraf/blob/main/README.md

  3. Or call the command in a package.json script.

    rimraf <path> [<path> ...]

    From github.com/isaacs/rimraf/blob/main/README.md

Mistakes to avoid

import rimraf from 'rimraf' or const rimraf = require('rimraf')
import { rimraf } from 'rimraf' or const { rimraf } = require('rimraf')

Since version 5 there is no default export; code from old tutorials fails with 'not a function'.

rimraf('dist', (err) => { ... })
await rimraf('dist')

Since version 4 the function returns a Promise and takes no callback.

rimraf('dist/**/*.map') expecting a pattern match
rimraf('dist/**/*.map', { glob: true }) or rimraf --glob 'dist/**/*.map'

Without the glob option the string is treated as one literal path.

await rimraf(req.body.folder)
Build the path yourself from a fixed base folder and an id you checked; never pass raw user input

The README says reports that rely on untrusted input will be rejected; the risk is on you.

"rimraf": "^3.0.2" in package.json
"rimraf": "^6.1.4" (Node 20 or 22+), or 5.x for older Node

npm marks every version before 4 as no longer supported.

Questions

Does it put files in the trash?

No. It deletes them for good; its purpose is permanent removal.

Why does rimraf('*.log') not delete my log files?

Patterns are off by default. Pass { glob: true } in code or --glob on the command line.

What does it return?

true when everything was removed; false only when a filter kept something. A missing path also gave true in our run.

Is the sync version faster?

Usually not. The README says the synchronous form is typically much slower than the async one.

Can it delete the root folder by mistake?

Not by default: removing / is refused unless you pass --no-preserve-root or preserveRoot: false.