# unionfs

> Use multiple `fs` modules in a union.

Latest version **4.6.0** (published 2025-07-18) · 2.2M weekly downloads

## Install

```sh
npm install unionfs
pnpm add unionfs
yarn add unionfs
bun add unionfs
```

## Health

**Score 55/100 (C)** — status: maintenance-mode.

Positive: high downloads; has types; no vulnerabilities; high quality score.

Warnings: no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.6.0 |
| Published | 2025-07-18 |
| First published | 2015-06-14 |
| Weekly downloads | 2.2M |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 39.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 238 |
| Maintainers | streamich |
| Keywords | fs, file, file system, mount, union, unionfs, many file systems, multiple |

## Links

- npm: https://www.npmjs.com/package/unionfs
- Repository: https://github.com/streamich/unionfs
- Homepage: https://github.com/streamich/unionfs#readme
- Issues: https://github.com/streamich/unionfs/issues
- npm.io page: https://npm.io/package/unionfs

## Dependencies (1)

- [fs-monkey](https://npm.io/package/fs-monkey.md) ^1.0.0

## Alternatives

- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads
- [restbox](https://npm.io/package/restbox.md) — 328 weekly downloads

## Recent versions

- 4.6.0 (latest) — 2025-07-18
- 4.5.4 — 2024-03-19
- 4.5.3 — 2024-03-19
- 4.5.2 — 2024-03-19
- 4.5.1 — 2023-06-03
- 4.5.0 — 2023-06-02
- 4.4.0 — 2020-03-12
- 4.3.2 — 2020-02-17
- 4.3.1 — 2020-02-15
- 4.3.0 — 2020-02-15
- 4.2.1 — 2019-12-19
- 4.2.0 — 2019-03-02
- 4.1.0 — 2019-03-01
- 4.0.0 — 2019-01-30
- 3.0.2 — 2017-12-08
- … 15 more at https://npm.io/package/unionfs/versions

## README

# unionfs

Creates a union of multiple `fs` file systems.

[![][npm-img]][npm-url] [![][travis-badge]][travis-url]

    npm install --save unionfs

This module allows you to use multiple objects that have file system `fs` API at the same time.

```js
import { ufs } from 'unionfs';
import { fs as fs1 } from 'memfs';
import * as fs2 from 'fs';

ufs.use(fs1).use(fs2);

ufs.readFileSync(/* ... */);
```

Use this module with [`memfs`][memfs] and [`linkfs`][linkfs].
`memfs` allows you to create virtual in-memory file system. `linkfs` allows you to redirect `fs` paths.

You can also use other _fs-like_ objects.

```js
import * as fs from 'fs';
import { Volume } from 'memfs';
import * as MemoryFileSystem from 'memory-fs';
import { ufs } from 'unionfs';

const vol1 = Volume.fromJSON({ '/memfs-1': '1' });
const vol2 = Volume.fromJSON({ '/memfs-2': '2' });

const memoryFs = new MemoryFileSystem();
memoryFs.writeFileSync('/memory-fs', '3');

ufs.use(fs).use(vol1).use(vol2).use(memoryFs);

console.log(ufs.readFileSync('/memfs-1', 'utf8')); // 1
console.log(ufs.readFileSync('/memfs-2', 'utf8')); // 2
console.log(ufs.readFileSync('/memory-fs', 'utf8')); // 3
```

You can create a `Union` instance manually:

```javascript
import { Union } from 'unionfs';

var ufs1 = new Union();
ufs1.use(fs).use(vol);

var ufs2 = new Union();
ufs2.use(fs).use(/*...*/);
```

[npm-url]: https://www.npmjs.com/package/unionfs
[npm-img]: https://img.shields.io/npm/v/unionfs.svg
[memfs]: https://github.com/streamich/memfs
[unionfs]: https://github.com/streamich/unionfs
[linkfs]: https://github.com/streamich/linkfs
[fs-monkey]: https://github.com/streamich/fs-monkey
[travis-url]: https://travis-ci.org/streamich/unionfs
[travis-badge]: https://travis-ci.org/streamich/unionfs.svg?branch=master

# License

[Unlicense](./LICENSE) - public domain.

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