memory-fs provides a simple, synchronous and asynchronous, in-memory filesystem abstraction, designed to hold data entirely within a JavaScript object. It mirrors a subset of the Node.js `fs` module API, making it suitable for scenarios where persistent disk I/O is undesirable or impractical, such as build tools, bundlers, and testing environments. The current stable version, 0.5.0, was released in 2017. While not actively developing new features, it is a critical, stable dependency for projects like Webpack, which relies on it for fast, transient asset compilation. Its primary differentiator is its complete in-memory operation and direct API compatibility with many standard `fs` methods, offering a performant alternative to disk-based operations for temporary file storage.
npm install memory-fsVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic synchronous and asynchronous file operations (create, write, read, delete, list, stat) using the `memory-fs` API.
Ensure your Node.js environment matches the specified engine compatibility range or use a tool like `nvm` to manage Node.js versions.
Always check the `memory-fs` documentation or source code for method availability. Do not assume full `fs` compatibility.
Use CommonJS `require()` syntax: `const MemoryFileSystem = require('memory-fs');`.After `require('memory-fs')`, always call `new MemoryFileSystem()` to get an instance, e.g., `const fs = new MemoryFileSystem();`.Ensure `const MemoryFileSystem = require('memory-fs');` directly assigns the constructor to `MemoryFileSystem` and then `const fs = new MemoryFileSystem();` is called.This package is CommonJS-only. For projects using ES modules, you might need to use a bundler (like Webpack) that handles CommonJS dependencies, or restructure your code to load this module in a CommonJS context.
Verify that the specific `fs` method you need is supported by `memory-fs`. If not, you may need to reconsider its use for that particular operation or find an alternative library.
No dependency data recorded yet.