Latest Threat Research:Malicious dYdX Packages Published to npm and PyPI After Maintainer Compromise.Details
Socket
Book a DemoInstallSign in
Socket

memfs

Package Overview
Dependencies
Maintainers
1
Versions
226
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

memfs

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

Source
npmnpm
Version
4.56.9
Version published
Weekly downloads
28M
1.7%
Maintainers
1
Weekly downloads
 
Created
Source

memfs

In-memory file system with Node.js fs API and browser File System (Access) API.

npm

Overview

memfs is a JavaScript library that implements an in-memory file system compatible with Node.js fs module and the browser File System (Access) API. Use it for testing, mocking file systems, or creating virtual file systems in both Node.js and browser environments.

Installation

npm install memfs

Quick Start

Node.js fs API

import { fs } from 'memfs';

// Write a file
fs.writeFileSync('/hello.txt', 'Hello, World!');

// Read a file
const content = fs.readFileSync('/hello.txt', 'utf-8');
console.log(content); // "Hello, World!"

// Create a directory
fs.mkdirSync('/mydir');

// List directory contents
console.log(fs.readdirSync('/')); // ['hello.txt', 'mydir']

Browser File System API

import { fsa } from 'memfs';

// Get root directory handle
const root = await fsa.getRoot();

// Create a file
const file = await root.getFileHandle('hello.txt', { create: true });
const writable = await file.createWritable();
await writable.write('Hello, World!');
await writable.close();

// Read the file
const readable = await file.getFile();
const text = await readable.text();
console.log(text); // "Hello, World!"

Features

  • Node.js fs module API compatibility
  • Browser File System (Access) API implementation
  • Adapters between fs and File System API
  • Directory snapshots and tree printing utilities
  • Works in Node.js and modern browsers
  • TypeScript support

Documentation

For detailed documentation and more examples, visit the main project page.

License

Apache 2.0

Keywords

fs

FAQs

Package last updated on 21 Jan 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts