Index of every page on this site: llms.txt
All skills
jasnell avatar

/node-vfs

@5f83e6c
Run it yourself

Node.js now has a built-in virtual file system, node:vfs, plus single executable apps with bundled assets (--build-sea). Use whenever code that uses fs must be tested without touching the real disk (instead of memfs/mock-fs or stubbing fs), bundle assets or a whole app into one executable, import or run modules from a zip, or overlay a directory copy-on-write. Covers vfs.create, MemoryProvider, ComposableProvider, RealFSProvider, ZipProvider, mount, --vfs-load, --allow-fs-vfs and SEA useVfs/vfsArchive. Node.js 26.4+ (not on v24; needs --experimental-vfs on 26.x).

Use this Skill: https://skilld.dev/gh/jasnell/node-skills/node-vfs

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

rulesflags-security.md

≈725 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Flags, versions, permissions, and security

Enabling node:vfs (verified)

Binary require('node:vfs') Notes
v24.19.0 ERR_UNKNOWN_BUILTIN_MODULE --experimental-vfs gives bad option. Not available on v24.
v26.13.0 needs --experimental-vfs --vfs-load without the flag fails: "--vfs-load requires --experimental-vfs" (exit 9).
v28.0.0-pre (main) works unflagged --experimental-vfs is still accepted. --no-experimental-vfs disables both the module and --vfs-load.

In cli.md, the --no-experimental-vfs entry records the change "VFS is unflagged but still experimental" for v27.0.0-alpha.0.0.0. On code that must run on 26.x, passing --experimental-vfs is harmless on main.

For SEAs, "useVfs" needs no flag. A SEA built with v26.13.0 mounted its assets without --experimental-vfs (verified).

--vfs-load=source (v26.10.0)

  • source can be a directory, mounted with RealFSProvider, or a file whose bytes are a ZIP of any name, mounted with ZipProvider. Providers from vfs.registerProvider() are consulted first. A source nobody claims is an error (ERR_VFS_INVALID_TARGET, verified for a plain text file).
  • The entry point is chosen like node <dir>: the mount's package.json "main", or index.js. Positional arguments belong to the program, and process.argv[1] reports source (verified).
  • The flag may be given at most once, and it is not allowed in NODE_OPTIONS (verified).
  • Workers inherit the mount unless they get their own execArgv. In that case, pass --vfs-load again.
  • It cannot be used inside a SEA.

Permission model

  • With --permission, vfs.mount() throws ERR_INVALID_STATE ("Use --allow-fs-vfs") unless you pass --allow-fs-vfs (v26.9.0, Stability 1.1). Verified on main.
  • --allow-fs-read and --allow-fs-write do not gate VFS paths. A mounted VFS serves paths that those permissions don't describe.
  • In --permission-audit mode, mounting is not refused and nothing is published to the diagnostics channel (docs).

Security (docs plus observed behavior)

  • VFS is not a sandbox or access-control mechanism. Code that can reach a VirtualFileSystem instance, or pass paths to it, is trusted code. Mounting redirects only node:fs calls under the mount point. Everything else still reaches the real system. For isolation, use OS users, containers, or a platform sandbox.
  • RealFSProvider's root check is not a boundary. Observed on v26.13.0 and main: a symlink inside the root that points outside it is followed by readFileSync. Only realpathSync rejects it, with EACCES.
  • Mounts live under a reserved namespace that cannot exist on disk (/dev/null/vfs/<n>), so a VFS never shadows real paths. That is also why it cannot fake fixed paths like /etc/app.json the way mock-fs does.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

1 warning5d3 checks · Risk SAFE
  • Gen Agent Trust Hub5d

    The skill provides comprehensive documentation and verified examples for the experimental `node:vfs` API and VFS-backed Single Executable Applications (SEA). It correctly identifies security considerations, such as the fact that `RealFSProvider` does not function as a sandbox, and its examples use standard Node.js APIs for feature verification and building binaries in temporary directories.

  • Socket5d

    1 alert: gptAnomaly

  • Snyk5d

    Risk: LOW · No issues

Signed by skilld at 5f83e6c. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 5 days ago.

Activeupdated last week

README badge

README badge for jasnell/node-skills/node-vfs