vfs.mountPointURL
当前挂载点作为 file: URL 字符串(vfs.mountPoint 路径经过 url.pathToFileURL() 转换),或者当 VFS 未挂载时为 null。
🌐 The current mount point as a file: URL string (the vfs.mountPoint
path converted with url.pathToFileURL()), or null when the VFS
is not mounted.
这是为了方便使用基于 URL 的 API(例如动态 import())来访问挂载的文件:
🌐 This is a convenience for addressing mounted files with URL-based
APIs such as dynamic import():
import vfs from 'node:vfs';
const myVfs = vfs.create();
myVfs.writeFileSync('/mod.mjs', 'export const value = 42;');
myVfs.mount();
const { value } = await import(`${myVfs.mountPointURL}/mod.mjs`);
console.log(value); // 42
myVfs.unmount();