Using memfs:
const { fs } = require('memfs');
fs.writeFileSync('/foo', 'hello');
fs.readFileSync('/foo/bar'); // throws ENOENT
Using the builtin fs (on Linux):
const fs = require('node:fs');
fs.writeFileSync('/foo', 'hello');
fs.readFileSync('/foo/bar'); // throws ENOTDIR
Using the builtin fs (on Windows):
const fs = require('node:fs');
fs.writeFileSync('C:/foo', 'hello');
fs.readFileSync('C:/foo/bar'); // throws ENOENT
I'm not sure which behavior makes more sense and if this difference is a bug in Node.js, but I think that if !isWin then memfs should also throw ENOTDIR.
Using
memfs:Using the builtin
fs(on Linux):Using the builtin
fs(on Windows):I'm not sure which behavior makes more sense and if this difference is a bug in Node.js, but I think that if
!isWinthenmemfsshould also throwENOTDIR.