method
vfs.MemoryProvider.setReadOnly
Locks the provider into read-only mode. Subsequent writes through any VirtualFileSystem using this provider throw EROFS. There is no way to revert the provider to writable.
const vfs = require('node:vfs');
const provider = new vfs.MemoryProvider();
const myVfs = vfs.create(provider);
myVfs.writeFileSync('/seed.txt', 'initial');
provider.setReadOnly();
myVfs.writeFileSync('/x.txt', 'fail'); // throws EROFS