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.md2. Maintained
github.com/isaacs/rimraf3. Used by agents' projects
Dependency in 161 public GitHub projects set up for AI coding agents that we scanned (2.6%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
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
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
Often used with
More about rimraf
Funding
- GitHub Sponsors: https://github.com/isaacs
- 23 GitHub sponsors
More in Dev workflow and config
Alternatives
rimraf This page
Pick del when you want to delete by glob patterns as the normal way of working, from Node.js code.
Pick shx when your scripts need several shell commands (copy, move, make folders), not just delete.
Pick fs-extra when your code also copies and creates folders and you want one helper package for all of it.
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.”
Import the function by name and await it with a path or a list of paths.
import { rimraf, rimrafSync, native, nativeSync } from 'rimraf'Or call the command in a package.json script.
rimraf <path> [<path> ...]
Mistakes to avoid
Since version 5 there is no default export; code from old tutorials fails with 'not a function'.
Since version 4 the function returns a Promise and takes no callback.
Without the glob option the string is treated as one literal path.
The README says reports that rely on untrusted input will be rejected; the risk is on you.
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.