Skip to content

Using a file as a directory throws ENOENT instead of ENOTDIR #1050

@SnirBroshi

Description

@SnirBroshi

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.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions