{"id":712,"url":"https://github.com/isaacs/rimraf","last_synced_at":"2025-05-13T20:05:07.956Z","repository":{"id":39460563,"uuid":"1341324","full_name":"isaacs/rimraf","owner":"isaacs","description":"A `rm -rf` util for nodejs","archived":false,"fork":false,"pushed_at":"2024-07-31T19:25:41.000Z","size":948,"stargazers_count":5754,"open_issues_count":13,"forks_count":255,"subscribers_count":43,"default_branch":"main","last_synced_at":"2025-05-06T19:52:02.725Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/isaacs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["isaacs"]}},"created_at":"2011-02-08T08:58:20.000Z","updated_at":"2025-05-06T14:53:33.000Z","dependencies_parsed_at":"2023-02-10T19:30:16.979Z","dependency_job_id":"9a109e0a-7ba9-4bce-b799-f817dc124c2d","html_url":"https://github.com/isaacs/rimraf","commit_stats":{"total_commits":316,"total_committers":33,"mean_commits":9.575757575757576,"dds":0.129746835443038,"last_synced_commit":"8733d4c30078a1ae5f18bb6affe83c1eea0259b4"},"previous_names":[],"tags_count":81,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isaacs%2Frimraf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isaacs%2Frimraf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isaacs%2Frimraf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isaacs%2Frimraf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/isaacs","download_url":"https://codeload.github.com/isaacs/rimraf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252788525,"owners_count":21804284,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-01-05T20:15:29.424Z","updated_at":"2025-05-13T20:05:07.936Z","avatar_url":"https://github.com/isaacs.png","language":"TypeScript","readme":"The [UNIX command](\u003chttp://en.wikipedia.org/wiki/Rm_(Unix)\u003e) `rm -rf` for node\nin a cross-platform implementation.\n\nInstall with `npm install rimraf`.\n\n## Major Changes\n\n### v5 to v6\n\n- Require node `20` or `\u003e=22`\n- Add `--version` to CLI\n\n### v4 to v5\n\n- There is no default export anymore. Import the functions directly\n  using, e.g., `import { rimrafSync } from 'rimraf'`.\n\n### v3 to v4\n\n- The function returns a `Promise` instead of taking a callback.\n- Globbing requires the `--glob` CLI option or `glob` option property\n  to be set. (Removed in 4.0 and 4.1, opt-in support added in 4.2.)\n- Functions take arrays of paths, as well as a single path.\n- Native implementation used by default when available, except on\n  Windows, where this implementation is faster and more reliable.\n- New implementation on Windows, falling back to \"move then\n  remove\" strategy when exponential backoff for `EBUSY` fails to\n  resolve the situation.\n- Simplified implementation on POSIX, since the Windows\n  affordances are not necessary there.\n- As of 4.3, return/resolve value is boolean instead of undefined.\n\n## API\n\nHybrid module, load either with `import` or `require()`.\n\n```js\n// 'rimraf' export is the one you probably want, but other\n// strategies exported as well.\nimport { rimraf, rimrafSync, native, nativeSync } from 'rimraf'\n// or\nconst { rimraf, rimrafSync, native, nativeSync } = require('rimraf')\n```\n\nAll removal functions return a boolean indicating that all\nentries were successfully removed.\n\nThe only case in which this will not return `true` is if\nsomething was omitted from the removal via a `filter` option.\n\n### `rimraf(f, [opts]) -\u003e Promise`\n\nThis first parameter is a path or array of paths. The second\nargument is an options object.\n\nOptions:\n\n- `preserveRoot`: If set to boolean `false`, then allow the\n  recursive removal of the root directory. Otherwise, this is\n  not allowed.\n- `tmp`: Windows only. Temp folder to place files and\n  folders for the \"move then remove\" fallback. Must be on the\n  same physical device as the path being deleted. Defaults to\n  `os.tmpdir()` when that is on the same drive letter as the path\n  being deleted, or `${drive}:\\temp` if present, or `${drive}:\\`\n  if not.\n- `maxRetries`: Windows and Native only. Maximum number of\n  retry attempts in case of `EBUSY`, `EMFILE`, and `ENFILE`\n  errors. Default `10` for Windows implementation, `0` for Native\n  implementation.\n- `backoff`: Windows only. Rate of exponential backoff for async\n  removal in case of `EBUSY`, `EMFILE`, and `ENFILE` errors.\n  Should be a number greater than 1. Default `1.2`\n- `maxBackoff`: Windows only. Maximum total backoff time in ms to\n  attempt asynchronous retries in case of `EBUSY`, `EMFILE`, and\n  `ENFILE` errors. Default `200`. With the default `1.2` backoff\n  rate, this results in 14 retries, with the final retry being\n  delayed 33ms.\n- `retryDelay`: Native only. Time to wait between retries, using\n  linear backoff. Default `100`.\n- `signal` Pass in an AbortSignal to cancel the directory\n  removal. This is useful when removing large folder structures,\n  if you'd like to limit the time spent.\n\n  Using a `signal` option prevents the use of Node's built-in\n  `fs.rm` because that implementation does not support abort\n  signals.\n\n- `glob` Boolean flag to treat path as glob pattern, or an object\n  specifying [`glob` options](https://github.com/isaacs/node-glob).\n- `filter` Method that returns a boolean indicating whether that\n  path should be deleted. With async `rimraf` methods, this may\n  return a Promise that resolves to a boolean. (Since Promises\n  are truthy, returning a Promise from a sync filter is the same\n  as just not filtering anything.)\n\n  The first argument to the filter is the path string. The\n  second argument is either a `Dirent` or `Stats` object for that\n  path. (The first path explored will be a `Stats`, the rest\n  will be `Dirent`.)\n\n  If a filter method is provided, it will _only_ remove entries\n  if the filter returns (or resolves to) a truthy value. Omitting\n  a directory will still allow its children to be removed, unless\n  they are also filtered out, but any parents of a filtered entry\n  will not be removed, since the directory will not be empty in\n  that case.\n\n  Using a filter method prevents the use of Node's built-in\n  `fs.rm` because that implementation does not support filtering.\n\nAny other options are provided to the native Node.js `fs.rm` implementation\nwhen that is used.\n\nThis will attempt to choose the best implementation, based on the Node.js\nversion and `process.platform`. To force a specific implementation, use\none of the other functions provided.\n\n### `rimraf.sync(f, [opts])` \u003cbr\u003e `rimraf.rimrafSync(f, [opts])`\n\nSynchronous form of `rimraf()`\n\nNote that, unlike many file system operations, the synchronous form will\ntypically be significantly _slower_ than the async form, because recursive\ndeletion is extremely parallelizable.\n\n### `rimraf.native(f, [opts])`\n\nUses the built-in `fs.rm` implementation that Node.js provides. This is\nused by default on Node.js versions greater than or equal to `14.14.0`.\n\n### `rimraf.native.sync(f, [opts])` \u003cbr\u003e `rimraf.nativeSync(f, [opts])`\n\nSynchronous form of `rimraf.native`\n\n### `rimraf.manual(f, [opts])`\n\nUse the JavaScript implementation appropriate for your operating system.\n\n### `rimraf.manual.sync(f, [opts])` \u003cbr\u003e `rimraf.manualSync(f, opts)`\n\nSynchronous form of `rimraf.manual()`\n\n### `rimraf.windows(f, [opts])`\n\nJavaScript implementation of file removal appropriate for Windows\nplatforms. Works around `unlink` and `rmdir` not being atomic\noperations, and `EPERM` when deleting files with certain\npermission modes.\n\nFirst deletes all non-directory files within the tree, and then\nremoves all directories, which should ideally be empty by that\ntime. When an `ENOTEMPTY` is raised in the second pass, falls\nback to the `rimraf.moveRemove` strategy as needed.\n\n### `rimraf.windows.sync(path, [opts])` \u003cbr\u003e `rimraf.windowsSync(path, [opts])`\n\nSynchronous form of `rimraf.windows()`\n\n### `rimraf.moveRemove(path, [opts])`\n\nMoves all files and folders to the parent directory of `path`\nwith a temporary filename prior to attempting to remove them.\n\nNote that, in cases where the operation fails, this _may_ leave\nfiles lying around in the parent directory with names like\n`.file-basename.txt.0.123412341`. Until the Windows kernel\nprovides a way to perform atomic `unlink` and `rmdir` operations,\nthis is, unfortunately, unavoidable.\n\nTo move files to a different temporary directory other than the\nparent, provide `opts.tmp`. Note that this _must_ be on the same\nphysical device as the folder being deleted, or else the\noperation will fail.\n\nThis is the slowest strategy, but most reliable on Windows\nplatforms. Used as a last-ditch fallback by `rimraf.windows()`.\n\n### `rimraf.moveRemove.sync(path, [opts])` \u003cbr\u003e `rimraf.moveRemoveSync(path, [opts])`\n\nSynchronous form of `rimraf.moveRemove()`\n\n### Command Line Interface\n\n```\nrimraf version 6.0.1\n\nUsage: rimraf \u003cpath\u003e [\u003cpath\u003e ...]\nDeletes all files and folders at \"path\", recursively.\n\nOptions:\n  --                   Treat all subsequent arguments as paths\n  -h --help            Display this usage info\n  --version            Display version\n  --preserve-root      Do not remove '/' recursively (default)\n  --no-preserve-root   Do not treat '/' specially\n  -G --no-glob         Treat arguments as literal paths, not globs (default)\n  -g --glob            Treat arguments as glob patterns\n  -v --verbose         Be verbose when deleting files, showing them as\n                       they are removed. Not compatible with --impl=native\n  -V --no-verbose      Be silent when deleting files, showing nothing as\n                       they are removed (default)\n  -i --interactive     Ask for confirmation before deleting anything\n                       Not compatible with --impl=native\n  -I --no-interactive  Do not ask for confirmation before deleting\n\n  --impl=\u003ctype\u003e        Specify the implementation to use:\n                       rimraf: choose the best option (default)\n                       native: the built-in implementation in Node.js\n                       manual: the platform-specific JS implementation\n                       posix: the Posix JS implementation\n                       windows: the Windows JS implementation (falls back to\n                                move-remove on ENOTEMPTY)\n                       move-remove: a slow reliable Windows fallback\n\nImplementation-specific options:\n  --tmp=\u003cpath\u003e        Temp file folder for 'move-remove' implementation\n  --max-retries=\u003cn\u003e   maxRetries for 'native' and 'windows' implementations\n  --retry-delay=\u003cn\u003e   retryDelay for 'native' implementation, default 100\n  --backoff=\u003cn\u003e       Exponential backoff factor for retries (default: 1.2)\n```\n\n## mkdirp\n\nIf you need to _create_ a directory recursively, check out\n[mkdirp](https://github.com/isaacs/node-mkdirp).\n","funding_links":["https://github.com/sponsors/isaacs"],"categories":["Node","命令行","目录","[Node.js](http://nodejs.org/) feature module and bundler","Packages","TypeScript","Applications","Repository","others","包","Uncategorized","脚手架以及工具包","JavaScript","📦 Modules/Packages","GIT 仓库","第三方库介绍","文件","Filesystem","Modules","模块","Cross-platform Utilities","Libraries","Node.js"],"sub_categories":["文件处理","redux 扩展","文件系统","Filesystem","Utilities","Uncategorized","macros",":curly_loop: Typography","文件管理","File System"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fisaacs%2Frimraf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fisaacs%2Frimraf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fisaacs%2Frimraf/lists"}