Entry Points

#Reference

The package has nine subpath exports. Each export loads only the code that it needs.

import fromwhat you get
mountx/autostart here: mount(), which selects a transport for the current host
mountxdriver types, capabilities, errors, path helpers, and the loopback harness
mountx/drivers/memoryan in-memory filesystem
mountx/drivers/node-fsa passthrough driver for a real directory
mountx/drivers/unstoragean adapter for an unstorage Storage
mountx/fusethe FUSE transport, when you must select it directly
mountx/9pthe 9P2000.L transport and createP9Server()
mountx/nfsthe NFS transport (v3 by default, v4.1 on request) and createNfsServer()
mountx/s3the S3 gateway and createS3Server(); this is not a mount transport
mountx/webdavthe WebDAV server and createWebdavServer(); this is not a mount transport

The guide documents the three mountx/drivers/* subpaths next to the interface that they implement. See Built-in drivers.

The Transports section documents mountx/auto and the five transport subpaths. It also explains the protocols.

The package also installs the mountx command-line interface (CLI). The CLI is a demonstration and test tool. Its documentation is in the guide.

#The mountx root export

The root export contains the APIs on the five pages in this section. It does not include transport code. Therefore, import … from "mountx" loads only the types and a small set of functions.

pageAPIs
Driver interfaceFsDriver, StatsLike, DirentLike, StatsFsLike, FileHandleLike, and the S_IF* bits
CapabilitiesFsCapabilities, resolveCapabilities(), and the mountx.* extension namespace
ErrorsfsError(), isFsError(), errnoOf(), ERRNO_CODES, and rangeError()
Loopback harnesscreateLoopback(), which runs a driver without a kernel
Paths and lockingnormalizePath() and related helpers, plus PathLock

#What to import

Use mountx/auto unless you must select a specific transport. It checks the host and returns the selected transport's mount object. The object includes a transport tag.

import { mount } from "mountx/auto";
import { createLoopback } from "mountx";
import { createMemoryDriver } from "mountx/drivers/memory";

Each subpath loads only the code that it needs. mountx/auto loads a selected transport with await import(). Selecting FUSE does not load the 9P or NFS stack. The probe loads only three small host checks. It does not load a protocol codec.

Note

mount is intentionally not exported from the mountx root. If it were exported there, each import … from "mountx" would load the protocol layer, the session, and node:child_process. This adds about 90 kB. The transport must be selected separately in all cases.

#Type-level guarantees

Continuous integration (CI) checks these two TypeScript guarantees:

  • FsDriver is a subset of node:fs/promises. const driver: FsDriver = await import("node:fs/promises") must compile without a cast.
  • AutoMount is a discriminated union. Check mounted.transport to access all members for that transport. You do not need a cast or optional chaining.

#Platform support

LinuxmacOSWindows
createLoopback
createNfsServer
createP9Server
createS3Server
mount (FUSE)
mount9p✅ root
mountNfs✅ root✅ no root
mount (auto)✅ FUSE, then 9P, then NFS✅ NFS

createP9Server runs on every platform that supports Node. Only mount9p() requires Linux and root. mountx/nfs has the same separation between createNfsServer and mountNfs.

Most transport modules perform only data transformation and run on any platform. In mountx/fuse, this includes every file except mount.ts. In mountx/9p and mountx/nfs, it includes every file except server.ts and mount.ts. The server files are portable Node socket servers. Only the mount files have platform requirements.

mountx  Write a filesystem in JavaScript, mount it as a real folder.