Getting EISDIR error from NodeJS when attempting to start app via Expo (React Native)

Viewed 3811

I'm getting the old 'directory is not a file' error with Node, and the output does not make it clear what exactly it's trying to parse. I've tried putting logging in and everything to find the issue, and even created a brand new project but the issue persists. Can anyone shed any light on this?

Error: EISDIR: illegal operation on a directory, read
at Object.readSync (fs.js:592:3)
at tryReadSync (fs.js:366:20)
at Object.readFileSync (fs.js:403:19)
at UnableToResolveError.buildCodeFrameMessage (C:\Users\thepo\Applications\WakeMyPC\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:304:17)
at new UnableToResolveError (C:\Users\thepo\Applications\WakeMyPC\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:290:35)
at ModuleResolver.resolveDependency (C:\Users\thepo\Applications\WakeMyPC\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:168:15)
at DependencyGraph.resolveDependency (C:\Users\thepo\Applications\WakeMyPC\node_modules\metro\src\node-haste\DependencyGraph.js:353:43)
at C:\Users\thepo\Applications\WakeMyPC\node_modules\metro\src\lib\transformHelpers.js:271:42
at C:\Users\thepo\Applications\WakeMyPC\node_modules\metro\src\Server.js:1098:37
at Generator.next (<anonymous>)
3 Answers

The problem turned out to be that some of the versions of modules that I installed using npm were not compatible with expo. These were indicated earlier than the error in the output for the 'expo start' command. Because these were info logs, I didn't pay enough attention to them. However, after several hours I decided to fix them and it fixed my problem.

The fix was to follow each individual package named in the output and run 'expo install '.

Make sure the entryPoint key in your app.config.js or app.json file is correctly set.

I had an intermittent error very similar to this and it was related to a bug with remote debugging.

Turning off "Debug Remote JS" in the Expo Go app shake-to-show developer menu avoided this issue for me (logs and errors still show in the Metro console).


Here's the exact error message I was getting (and sometimes the app would just fail silently without any error). It's almost identical to the error in the question with a few different line numbers (maybe from different versions).

Error: EISDIR: illegal operation on a directory, read
    at Object.readSync (node:fs:721:3)
    at tryReadSync (node:fs:431:20)
    at Object.readFileSync (node:fs:477:19)
    at UnableToResolveError.buildCodeFrameMessage 

As for "why", there's some related discussion on this expo forum thread which in turn links to this React Native bug (claimed to be fixed in Expo CLI 4.13.1 but many users reporting similar issues in recent versions).

It might be related to the reported issues with Reanimated 2 and Expo's remote debugging (see this reanimated issue and the warning note in Expo's documentation) for Reanimated.

Related