metro: 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.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 45
- Comments: 28
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
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’ve the same issue. I’ve solve it by adding to
metro.config.jsnext lines :I hope this can help you
@huhuang03 Disable the Google debugging tool JavaScript Source Maps and CSS Source Map, The error goes away
+1
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 orfs.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 😃@lpetka please can you expatiate on your suggestion? How did you attach the debugger via react-native-debugger?
I got same error, but all going well after I
yarn global remove wmlthat 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
wmlstaff, but I found my issue’s root cause was thewatchman, after runbrew uninstall watchman, all going wellFor 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.
still got the same issue
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 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 ?
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-reanimatedlibrary. There’s a known bug that breaks the debugger.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.
Same here, failing to resolve
/my-root/.originating in requestProcessor()metro@0.59.0 expo@42.0.4 node v14.18.0 npm v8.0.0
I’m facing the sam issue. If this is gonna help somebody - attaching the debugger via
react-native-debuggerapp works like a charm.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.