Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including unionfs with all npm packages installed. Try it out:

var unionfs = require("unionfs")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

unionfs v4.4.0

Use multiple `fs` modules in a union.


Creates a union of multiple fs file systems.

npm install --save unionfs

This module allows you to use multiple objects that have file system fs API at the same time.

import {ufs} from 'unionfs';
import {fs as fs1} from 'memfs';
import * as fs2 from 'fs';


ufs.readFileSync(/* ... */);

Use this module with memfs and linkfs. memfs allows you to create virtual in-memory file system. linkfs allows you to redirect fs paths.

You can also use other fs-like objects.

import * as fs from 'fs';
import {Volume} from 'memfs';
import * as MemoryFileSystem from 'memory-fs';
import {ufs} from 'unionfs'

const vol1 = Volume.fromJSON({'/memfs-1': '1'});
const vol2 = Volume.fromJSON({'/memfs-2': '2'});

const memoryFs = new MemoryFileSystem;
memoryFs.writeFileSync('/memory-fs', '3');


console.log(ufs.readFileSync('/memfs-1', 'utf8')); // 1
console.log(ufs.readFileSync('/memfs-2', 'utf8')); // 2
console.log(ufs.readFileSync('/memory-fs', 'utf8')); // 3

You can create a Union instance manually:

import {Union} from 'unionfs';

var ufs1 = new Union;

var ufs2 = new Union;


Unlicense - public domain.


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free