streamich/memfs

Node.js "fs" and browser "File System API" adapters and in-memory implementations 👍

2,093

stars

2,152

commits

TypeScript

primary language

Sep 9, 2026

updated

jsonjoy.com/libs/memfs
browserfs
cas
crud
file
file-system
filesystem
fs
fsa
in-memory
memfs
memory
node
opfs
webfs
Browse cluster: ESLint plugins and browser compatibility

README

memfs

JavaScript file system utilities for Node.js and browser. Implementation of in-memory Node.js fs module API and in-memory browser File System API, as well as adapters from fs module to File Sytem API and from File Sytem API to fs module.

Install

npm i memfs

Resources

Watching

All file-watching APIs are implemented on both sides of the fs and File System API divide:

FeaturePackageNotes
fs.watchrecursive, encoding, signal, throwIfNoEntry, ignore@jsonjoy.com/fs-node'error'/'close' events, ref()/unref()
fs.watchFile / fs.unwatchFile@jsonjoy.com/fs-nodepolling, bigint, Node's reappearance semantics
fs.promises.watch async iterator@jsonjoy.com/fs-nodemaxQueue, overflow, AbortError on abort
FileSystemObserver@jsonjoy.com/fs-fsadeterministic OPFS profile: precise records, real "moved" records, microtask batching
fs.watch/fs.watchFile over a real FSA directory@jsonjoy.com/fs-fsa-to-nodeworks over OPFS in Chrome 133+ via the native observer
FileSystemObserver over any fs@jsonjoy.com/fs-node-to-fsabest-effort profile: renames stat-classified, no "moved" records

Intentional divergences from real watchers (the in-memory backend is deterministic, so platform unreliability is not emulated):

  • Paths are watched semantically rather than by inode: after delete-and-recreate, memfs reports events for the recreated entry, while a real POSIX watcher keeps watching the dead inode.
  • Exactly one event per logical operation — no platform duplicate events.
  • filename is never null.
  • The Node-style FSWatcher delivers events synchronously inside the mutating operation, whereas real Node defers to the event loop; the FileSystemObserver batches per microtask, as the spec requires.

Demos

See also

  • unionfs - creates a union of multiple filesystem volumes
  • fs-monkey - monkey-patches Node's fs module and require function
  • linkfs - redirects filesystem paths
  • spyfs - spies on filesystem actions

License

Apache 2.0

Contributors

(top 30 of 68)

streamich

989 commits

renovate-bot

530 commits

Copilot

141 commits

streamich/memfs

Node.js "fs" and browser "File System API" adapters and in-memory implementations 👍

2,093

stars

2,152

commits

TypeScript

primary language

Sep 9, 2026

updated

jsonjoy.com/libs/memfs
browserfs
cas
crud
file
file-system
filesystem
fs
fsa
in-memory
memfs
memory
node
opfs
webfs
Browse cluster: ESLint plugins and browser compatibility

README

memfs

JavaScript file system utilities for Node.js and browser. Implementation of in-memory Node.js fs module API and in-memory browser File System API, as well as adapters from fs module to File Sytem API and from File Sytem API to fs module.

Install

npm i memfs

Resources

Watching

All file-watching APIs are implemented on both sides of the fs and File System API divide:

FeaturePackageNotes
fs.watchrecursive, encoding, signal, throwIfNoEntry, ignore@jsonjoy.com/fs-node'error'/'close' events, ref()/unref()
fs.watchFile / fs.unwatchFile@jsonjoy.com/fs-nodepolling, bigint, Node's reappearance semantics
fs.promises.watch async iterator@jsonjoy.com/fs-nodemaxQueue, overflow, AbortError on abort
FileSystemObserver@jsonjoy.com/fs-fsadeterministic OPFS profile: precise records, real "moved" records, microtask batching
fs.watch/fs.watchFile over a real FSA directory@jsonjoy.com/fs-fsa-to-nodeworks over OPFS in Chrome 133+ via the native observer
FileSystemObserver over any fs@jsonjoy.com/fs-node-to-fsabest-effort profile: renames stat-classified, no "moved" records

Intentional divergences from real watchers (the in-memory backend is deterministic, so platform unreliability is not emulated):

  • Paths are watched semantically rather than by inode: after delete-and-recreate, memfs reports events for the recreated entry, while a real POSIX watcher keeps watching the dead inode.
  • Exactly one event per logical operation — no platform duplicate events.
  • filename is never null.
  • The Node-style FSWatcher delivers events synchronously inside the mutating operation, whereas real Node defers to the event loop; the FileSystemObserver batches per microtask, as the spec requires.

Demos

See also

  • unionfs - creates a union of multiple filesystem volumes
  • fs-monkey - monkey-patches Node's fs module and require function
  • linkfs - redirects filesystem paths
  • spyfs - spies on filesystem actions

License

Apache 2.0

Contributors

(top 30 of 68)

streamich

989 commits

renovate-bot

530 commits

Copilot

141 commits

Languages

TypeScript

98.6%