# mem-fs

> Simple in-memory vinyl file store

Latest version **6.0.0** (published 2026-08-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install mem-fs
pnpm add mem-fs
yarn add mem-fs
bun add mem-fs
```

## Health

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

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 6.0.0 |
| Published | 2026-08-24 |
| First published | 2014-11-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18.0.0 |
| Dependencies | 2 |
| Unpacked size | 9.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 128 |
| Author | Simon Boudrias |
| Maintainers | sboudrias, mshima |

## Links

- npm: https://www.npmjs.com/package/mem-fs
- Repository: https://github.com/SBoudrias/mem-fs
- Homepage: https://github.com/SBoudrias/mem-fs#readme
- Issues: https://github.com/SBoudrias/mem-fs/issues
- npm.io page: https://npm.io/package/mem-fs

## Dependencies (2)

- [vinyl](https://npm.io/package/vinyl.md) ^3.0.1
- [vinyl-file](https://npm.io/package/vinyl-file.md) ^5.0.0

## Recent versions

- 6.0.0 (latest) — 2026-08-24
- 5.0.0 — 2026-08-16
- 4.1.5 — 2026-07-12
- 4.1.4 — 2026-02-26
- 4.1.3 — 2026-01-10
- 4.1.2 — 2024-12-12
- 4.1.1 — 2024-10-12
- 4.1.0 — 2024-02-26
- 4.0.0 — 2023-10-15
- 4.0.0-beta.1 — 2023-10-09
- 3.0.0 — 2023-04-17
- 2.3.0 — 2023-02-14
- 2.2.1 — 2021-05-26
- 2.2.0 — 2021-05-25
- 2.1.0 — 2021-04-30
- … 8 more at https://npm.io/package/mem-fs/versions

## README

# mem-fs

Simple in-memory vinyl file store.

## Usage

### Loading a file

You access a file using `store#get()` method. If the file is in memory, it will be used. Otherwise, we'll load the file from the file-system.

```js
import { create } from 'mem-fs';

const store = create();
store.get('/test/file.txt');
```

When trying to load a file we cannot read from disk, an empty Vinyl file will be returned. The `contents` of this file will be set to `null`.

Trying to get a directory or any invalid files will also return an empty Vinyl file pointer.

### Adding/updating a file

You update file references by using `store#add()` method. This method take a `vinyl` file object as parameter.

```js
import File from 'vinyl';
import { create } from 'mem-fs';

const coffeeFile = new File({
  cwd: '/',
  base: '/test/',
  path: '/test/file.coffee',
  contents: new Buffer('test = 123'),
});

const store = create();
store.add(coffeeFile);
```

### Iterating over the file system

Using `store#each(cb(file, index))`, you can iterate over every file stored in the file system.

### Get all files

Using `store#all()`, you can get every file stored in the file system.

### Check existence in the file system

Using `store#existsInMemory()`, you can check if the file already exists in the file system without loading it from disk.

### Stream every file stored in the file system

Using `store#stream()`, you can create a stream with every file stored in the file system.

### Pass stored files through a pipeline

`store#pipeline()` generates a new map with yielded files in transforms.
If no transform is passed, files references are updated.

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