Metro: Error: EISDIR: illegal operation on a directory, read

Created on 9 Apr 2021  路  12Comments  路  Source: facebook/metro

Do you want to request a feature or report a bug?
A bug I thingk.

What is the current behavior?

I have an project which is a react native project called th_views.rn and in the project there's a folder which is still a react native project named examples

Then I run npm run android in examples which run the react-native run-android. Then the error show:

file:  /my_porject_path/th_views.rn/examples/.
Error: EISDIR: illegal operation on a directory, read
    at Object.readSync (node:fs:625:3)
    at tryReadSync (node:fs:390:20)
    at Object.readFileSync (node:fs:427:19)
    at UnableToResolveError.buildCodeFrameMessage (/Volumes/wd/Previous Content/source/th_libs/rn/th_views.rn/examples/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:347:17)
    at new UnableToResolveError (/Volumes/wd/Previous Content/source/th_libs/rn/th_views.rn/examples/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:333:35)
    at ModuleResolver.resolveDependency (/Volumes/wd/Previous Content/source/th_libs/rn/th_views.rn/examples/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:211:15)
    at DependencyGraph.resolveDependency (/Volumes/wd/Previous Content/source/th_libs/rn/th_views.rn/examples/node_modules/metro/src/node-haste/DependencyGraph.js:413:43)
    at /Volumes/wd/Previous Content/source/th_libs/rn/th_views.rn/examples/node_modules/metro/src/lib/transformHelpers.js:317:42
    at /Volumes/wd/Previous Content/source/th_libs/rn/th_views.rn/examples/node_modules/metro/src/Server.js:1471:14
    at Generator.next (<anonymous>)

which the code around is node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:

  buildCodeFrameMessage() {
    let file;

    try {
      file = fs.readFileSync(this.originModulePath, "utf8");
    } catch (error) {
      if (error.code === "ENOENT") {
        // We're probably dealing with a virtualised file system where
        // `this.originModulePath` doesn't actually exist on disk.
        // We can't show a code frame, but there's no need to let this I/O
        // error shadow the original module resolution error.
        return null;
      }


      // I add for show the folder
      console.log("file: ", this.originModulePath)
      throw error;
    }

And the folder which perform read on is: /my_porject_path/th_views.rn/examples/.

It's strange that perform read on .. How can I debug or fix this. Thank you.

Most helpful comment

It seems like that the error occurs when I open Devtools.

I solved that according to the highest answer in this question https://stackoverflow.com/questions/61339968/devtools-failed-to-load-sourcemap-could-not-load-content-for-chrome-extension

All 12 comments

+1

Got the same issue

i am getting the same issue running on iOS... my app is hanging on splash screen with the same error message.
@huhuang03 did you find any fix for this ?

Got the same issue

It seems like that the error occurs when I open Devtools.

I solved that according to the highest answer in this question https://stackoverflow.com/questions/61339968/devtools-failed-to-load-sourcemap-could-not-load-content-for-chrome-extension

@huhuang03 : did you find any solution for this. we are struggling to get the solution. Please let us know if you got anything

@agrawalsurabhi89 Sorry I didn't...

@huhuang03 Disable the Google debugging tool JavaScript Source Maps and CSS Source Map,
The error goes away

Same here, trying to upgrade an app from Expo SDK 40 to 41.

An error in devtools related to source maps:

http://localhost:19000/debugger-ui/debuggerWorker.aca173c4.js.map

image

image

This is just annoying to have a console stacktrace on expo start, but it does not prevent the app to run in my case.

It seems like that the error occurs when I open Devtools.

I solved that according to the highest answer in this question https://stackoverflow.com/questions/61339968/devtools-failed-to-load-sourcemap-could-not-load-content-for-chrome-extension

Can you share the link to the answer to be more accurate?
Also it is true, I can only reproduce while debugging. if not the issue does not arise.

Go to the developer tools (F12 in the browser), then select the three dots in the upper right corner, and go to Settings.
Then, look for Sources, and disable the options: "Enable javascript source maps" "Enable CSS source maps"

Same issue here; assuming the stackoverflow url posted above is the quote above - this did not work. Same experience though, when I am not debugging the error magically goes away.

I'm facing the sam issue. If this is gonna help somebody - attaching the debugger via react-native-debugger app works like a charm.

image

Was this page helpful?
0 / 5 - 0 ratings