• Version 4.9.3
  • Published
  • 661 kB
  • 4 dependencies
  • Apache-2.0 license


npm i memfs
yarn add memfs
pnpm add memfs


In-memory file-system with Node's fs API.



variable fs

const fs: IFs;

    variable vol

    const vol: _Volume;

      variable Volume

      const Volume: typeof _Volume;


        function createFsFromVolume

        createFsFromVolume: (vol: _Volume) => IFs;

          function memfs

          memfs: (json?: NestedDirectoryJSON, cwd?: string) => { fs: IFs; vol: _Volume };
          • Creates a new file system instance.

            Parameter json

            File system structure expressed as a JSON object. Use null for empty directories and empty string for empty files.

            Parameter cwd

            Current working directory. The JSON structure will be created relative to this path.


            A memfs file system instance, which is a drop-in replacement for the fs module.


          interface DirectoryJSON

          interface DirectoryJSON<T extends DirectoryContent = DirectoryContent> {}

            index signature

            [key: string]: T;

              interface IFs

              interface IFs extends _Volume {}

                property constants

                constants: typeof constants;

                  property Dirent

                  Dirent: new (...args: any[]) => Dirent;

                    property FSWatcher

                    FSWatcher: new () => FSWatcher;

                      property promises

                      promises: FsPromisesApi;

                        property ReadStream

                        ReadStream: new (...args: any[]) => misc.IReadStream;

                          property Stats

                          Stats: new (...args: any[]) => Stats;

                            property StatWatcher

                            StatWatcher: new () => StatWatcher;

                              property WriteStream

                              WriteStream: new (...args: any[]) => IWriteStream;

                                interface NestedDirectoryJSON

                                interface NestedDirectoryJSON<T extends DirectoryContent = DirectoryContent> {}

                                  index signature

                                  [key: string]: T | NestedDirectoryJSON;

                                    Type Aliases

                                    type IFsWithVolume

                                    type IFsWithVolume = IFs & {
                                    __vol: _Volume;

                                      Package Files (2)

                                      Dependencies (4)

                                      Dev Dependencies (31)

                                      Peer Dependencies (0)

                                      No peer dependencies.


                                      To add a badge like this badgeto your package's README, use the codes available below.

                                      You may also use to create a custom badge linking to

                                      • Markdown
                                      • HTML
                                        <a href=""><img src="" alt=""></a>