Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: EISDIR: illegal operation on a directory, read at Object.readSync

when i enter to my react native application from android device the app crash and it's throw the next error:

image of the error:

enter image description here

thanks for helping I try to delete node modules and reinstall and delete the app and build again and it doesn't work

like image 986
LiavOzeri Avatar asked Sep 11 '25 04:09

LiavOzeri


1 Answers

This issue seems to be due to metro bundler and source maps requested by the browser (Chrome in my case), I've listed the steps below in solving this.

Note: The patch script mentioned below is only related to [email protected]. If you have another version, you can try modifying the script or searching through GitHub issues for metro for something related to your version.

  1. Install patch-package by running yarn add patch-package.
  2. Next, edit your package.json file and add this line within scripts:
"postinstall": "patch-package"
  1. Now mkdir patches in your project's root directory (if you don't have one already).
  2. Add the script below into patches/metro+0.64.0.patch:
diff --git a/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js b/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js
index 5f32fc5..2b80fda 100644
--- a/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js
+++ b/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js
@@ -346,7 +346,7 @@ class UnableToResolveError extends Error {
     try {
       file = fs.readFileSync(this.originModulePath, "utf8");
     } catch (error) {
-      if (error.code === "ENOENT") {
+      if (error.code === "ENOENT" || error.code === 'EISDIR') {
         // 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
  1. Run yarn postinstall and it should patch [email protected].

  2. In Chrome dev tools, uncheck:

    • Enable JavaScript source maps
    • Enable CSS source maps
  3. Run react-native start and you should be good to go.

Reference: GitHub => react-native-fs => Issue 991

like image 52
Zishan Neno Avatar answered Sep 13 '25 20:09

Zishan Neno