虚拟文件系统


🌐 Virtual File System

稳定性: 1 - 实验性

源代码: lib/vfs.js

node:vfs 模块提供了一个虚拟文件系统,具有类似 node:fs 的 API。它适用于测试、夹具、嵌入式资源以及其他需要自包含文件系统而不接触实际文件系统的场景。

🌐 The node:vfs module provides a virtual file system with a node:fs-like API. It is useful for tests, fixtures, embedded assets, and other scenarios where you need a self-contained file system without touching the actual file-system.

要访问它:

🌐 To access it:

import vfs from 'node:vfs';const vfs = require('node:vfs');

这个模块只在 node: 方案下可用,而且只有在用 --experimental-vfs 标志启动 Node.js 时才可用。

🌐 This module is only available under the node: scheme, and only when Node.js is started with the --experimental-vfs flag.