Error: EPERM: operation not permitted, lstat ...

I ejected to ExpoKit recently and followed the documentation, however, whenever I tried to run the app on any device or simulator the following error was thrown:
Error: EPERM: operation not permitted, lstat …
I scoured these forums and google in search for an aswer but none were sufficient.
I finally figured out that metro watches the android directory created by ExpoKit and this conflicts when Android Studio is building or cleaning, or anything else that manipulates the files in the android directory.
I figured out that I could make metro skip this directory by adding a metro.config.js file to my project root where I could set resolve.blacklistRE to exlude certain files or directories from the bundler.
I’m leaving this here in the hope it can help others.

My metro.config.js file is as follows:

var getBlacklistRE = function getBlacklistRE(){
	return new RegExp("(.*\\android\\.*|.*\\__fixtures__\\.*|node_modules[\\\\]react[\\\\]dist[\\\\].*|website\\node_modules\\.*|heapCapture\\bundle\.js|.*\\__tests__\\.*)$");
}

module.exports = {
	resolver: {
		"blacklistRE": getBlacklistRE(),
	}
};
7 Likes

You are a life saver! This fixed my issue with an Expokit project building to Android on Windows!

This has also worked for me.
But, could you explain what your regex does? what are the paths and directories that are being ignored? Are there any downsides of using this approach?
Hope you could answer.

There’s no downsides, the directories ignored aren’t any that you need metro to watch for changes.
I just added the android folder to what I found was the default ignore list.

1 Like

Excelent! Thanks for this solution, i was stuck on this for like a week.

Works for me

After making those changes are you directly run expo start?

Yes, I do.

yeah it works.thanks buddy