Node.js expected a file but received a directory path
EISDIR: illegal operation on a directory
EISDIR means a filesystem operation received a directory where it needed a file. Start with the error's path and syscall: reinstalling packages or changing permissions will not correct a path pointing at the wrong type of object.
A directory path was passed to code that expects a file.
Path building logic resolved to a folder instead of the intended file.
User input or configuration points at the wrong target path.
How to fix it
Inspect error.code, error.path, and error.syscall, then resolve the configured path against the process working directory. Relative paths can point somewhere different in a service, container, or CI runner.
For example, readFile('./config') targets a directory if config is a folder. Use the actual file path, such as './config/settings.json', after verifying it exists.
Inspect the target with fs.stat and isDirectory() when diagnosing the problem. Keep error handling around the actual read too, because a filesystem target can change between checking and opening it.
If you intend to list a directory, use fs.readdir rather than fs.readFile. Select a particular file before reading its contents.
Check container mounts and deployment configuration if the failure occurs only in production. Confirm the configured file was not replaced by a directory at the mount target.
Repeat the failing operation in the same working directory and runtime as the application. Do not delete the directory or broaden permissions as a generic workaround.