metro
metro copied to clipboard
Error: EISDIR: illegal operation on a directory, read
Do you want to request a feature or report a bug? A bug I think.
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.
+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
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.
@lpetka please can you expatiate on your suggestion? How did you attach the debugger via react-native-debugger?
I have installed [email protected] and this fixed my issues (after all warnings resolved and recommended versions installed)
I have installed [email protected] and the issue still persists :( MacOs Big Sur
Same here, failing to resolve /my-root/.
originating in requestProcessor()
[email protected] [email protected] node v14.18.0 npm v8.0.0
Error: EISDIR: illegal operation on a directory, read
at Object.readSync (fs.js:617:3)
at Object.readSync (/my-root/app/my-app/node_modules/graceful-fs/polyfills.js:147:28)
at tryReadSync (fs.js:382:20)
at Object.readFileSync (fs.js:419:19)
at UnableToResolveError.buildCodeFrameMessage (/my-root/app/my-app/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:304:17)
at new UnableToResolveError (/my-root/app/my-app/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:290:35)
at ModuleResolver.resolveDependency (/my-root/app/my-app/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:168:15)
at DependencyGraph.resolveDependency (/my-root/app/my-app/node_modules/metro/src/node-haste/DependencyGraph.js:353:43)
at /my-root/app/my-app/node_modules/metro/src/lib/transformHelpers.js:271:42
at Server.<anonymous> (/my-root/app/my-app/node_modules/metro/src/Server.js:842:41)
still got the same issue
i am stuck since 2 days... can anyone please post a solution...
For what it's worth... I still see this error and i've continued to ignore it. Everything in my app is working fine, my store builds work fine so until it breaks something I'll unfortunately continue to ignore it. I may try the solution mentioned by @lpetka; as it appears to be related to the debugger.
I've the same issue. I've solve it by adding to metro.config.js
next lines :
module.exports = (() => {
return {
resolver: {
sourceExts: ['cjs', 'js', 'ts', 'jsx', 'tsx'], // Adding here all needed extensions in your app
},
}
})()
I hope this can help you
i solved by this link here https://stackoverflow.com/questions/70405285/react-native-android-crashes-on-enabling-debug-mode ,react-native-reanimated no support on debug mode , some of the plugin no support debug mode, don't forget to check the plugin you install
I got the same issue:
`
Error: EISDIR: illegal operation on a directory, read`
  at Object.readSync (node:fs:723:3)
  at tryReadSync (node:fs:433:20)
  at Object.readFileSync (node:fs:479:19)
  at UnableToResolveError.buildCodeFrameMessage (node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:347:17)
  at new UnableToResolveError (/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:333:35)
  at ModuleResolver.resolveDependency (node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:211:15)
  at DependencyGraph.resolveDependency (node_modules/metro/src/node-haste/DependencyGraph.js:413:43)
  at node_modules/metro/src/lib/transformHelpers.js:317:42
  at node_modules/metro/src/Server.js:1471:14
  at Generator.next (<anonymous>)
[email protected] [email protected] node v16.14.0 yarn v1.22.17 MacOs Big Sur
But in my case I also can see this issue in my build. How can I fix this. Thank you.
bit of a old thread but i just solved this exact issue on a server I am running.
my issue was that i was using "readFileSync", when it came across a Directory and not a file, it threw that error.
my solution was simply re organize my file structure so that it does not come across a folder, for others you may want to implement some logic to not read a Directory's only files.
I got same error, but all going well after I yarn global remove wml
yarn global remove wml
that save my life
if you have never install wml
, just consider some other related global libs
----update-----
I got the error again even I uninstall wml
staff, but I found my issue's root cause was the watchman
, after run brew uninstall watchman
, all going well
@huhuang03 Disable the Google debugging tool JavaScript Source Maps and CSS Source Map, The error goes away
This is not a valid answer. The issue isn't about displaying an error. It's about the debugger preventing the app from loading, in my case.
I'm facing the sam issue. If this is gonna help somebody - attaching the debugger via
react-native-debugger
app works like a charm.
I'm glad it worked for you although I can't see how it did. RN Debugger is built on Chrome Devtools. If open, it redirects the app launch away from Devtools. I thought I'd try your solution hoping it'd work for me. Sadly, it did not.
For what it's worth... I still see this error and i've continued to ignore it. Everything in my app is working fine, my store builds work fine so until it breaks something I'll unfortunately continue to ignore it. I may try the solution mentioned by @lpetka; as it appears to be related to the debugger.
Unlike the OP, my app runs fine and I don't receive this error message as long as I don't try to launch a debugger. Once in debug mode, the app hangs at the splash screen. If I close the debugger, then app refreshes and works as intended. The really weird part of this is that this error just started appearing about 2 days ago. Before that, I used the debugger daily. No frikin idea what's going on.
What's even more surprising is that this issue has remained open for over a year now.
UPATE: I guess in my case, the problem resides with the react-native-reanimated
library. There's a known bug that breaks the debugger.
The fs.readFileSync()
function can not be used with a directory in parameter.
fs.readdirSync("D:\\Projects\\OGC\\assets\\Texture\\playingCards").forEach(file => {console.log(file);});
can be used to list all files in a directory
or
fs.readFileSync("D:\\Projects\\OGC\\assets\\favicon.ico").forEach(byte => {console.log(byte);});
to list all bytes of a file.
but not a mix of both :)