# fs-remove-compat

> Cross-platform file removal utilities with Node.js 0.8+ compatibility. Provides rm and rmSync ponyfills matching Node.js fs.rm API, plus safeRm/safeRmSync with Windows-friendly retry defaults.

Latest version **1.0.6** (published 2026-09-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install fs-remove-compat
pnpm add fs-remove-compat
yarn add fs-remove-compat
bun add fs-remove-compat
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2026-09-12 |
| First published | 2025-12-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=0.8 |
| Dependencies | 0 |
| Unpacked size | 123.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Kevin Malakoff |
| Maintainers | kmalakoff |
| Keywords | fs, rm, rmSync, remove, rimraf, polyfill, ponyfill, compat, node-0.8, windows |

## Links

- npm: https://www.npmjs.com/package/fs-remove-compat
- Repository: https://github.com/kmalakoff/fs-remove-compat
- Issues: https://github.com/kmalakoff/fs-remove-compat/issues
- npm.io page: https://npm.io/package/fs-remove-compat

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.6 (latest) — 2026-09-12
- 1.0.5 — 2026-09-04
- 1.0.4 — 2026-08-24
- 1.0.3 — 2026-05-26
- 1.0.2 — 2025-12-26
- 1.0.1 — 2025-12-19
- 1.0.0 — 2025-12-15
- 0.2.5 — 2025-12-15
- 0.2.4 — 2025-12-15
- 0.2.3 — 2025-12-12
- 0.2.2 — 2025-12-12
- 0.2.1 — 2025-12-05
- 0.2.0 — 2025-12-04
- 0.1.1 — 2025-12-04
- 0.1.0 — 2025-12-04

## README

# fs-remove-compat

Cross-platform file removal utilities with Node.js 0.8+ compatibility. The strict `rm` and `rmSync` functions match the Node.js `fs.rm` APIs. The `safeRm` and `safeRmSync` variants use Windows-friendly defaults for cleanup tasks.

## Install

```sh
npm install fs-remove-compat
```

## Use

This CommonJS example creates and removes a disposable file, then reports errors through the callback.

```js
var fs = require('fs');
var os = require('os');
var path = require('path');
var rm = require('fs-remove-compat').rm;

var file = path.join(os.tmpdir(), 'fs-remove-compat-example.txt');
fs.writeFileSync(file, 'temporary file');
rm(file, function (error) {
  if (error) throw error;
  console.log('Removed');
});
```

`rm` and `rmSync` default to `recursive: false`, `force: false`, and `maxRetries: 0`. `safeRm` and `safeRmSync` default to `recursive: true` and `force: true`; on Windows they retry removable errors up to 10 times. Pass `recursive: true` to remove a directory with the strict functions.

## API

```ts
interface RmOptions {
  recursive?: boolean;
  force?: boolean;
  maxRetries?: number;
  retryDelay?: number;
}
```

- `rm(path, [options], callback)` removes a file or directory asynchronously.
- `rmSync(path, [options])` removes a file or directory synchronously.
- `safeRm(path, [options], callback)` is the asynchronous cleanup variant.
- `safeRmSync(path, [options])` is the synchronous cleanup variant.

The asynchronous functions use Node-style callbacks. They do not return Promises. Use `safeRm` or `safeRmSync` for cleanup where Windows file locking is common. The package uses native `fs.rm` on Node 14.14 and newer and a fallback on older versions.

## License

MIT

---
_Source: https://npm.io/package/fs-remove-compat · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
