Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to resolve module ./.expo/.virtual-metro-entry

Actually I have installed unimodule previously was running react native cli because of tensorflow/tfjs-react-native I have to install unimodule but whenever I am doing yarn android I am getting below error Error: Unable to resolve module ./.expo/.virtual-metro-entry from /home/lipl-149/Desktop/Ankit/ReactJs/ReactNativeTry/.:

None of these files exist:

  • .expo/.virtual-metro-entry(.native|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
  • .expo/.virtual-metro-entry/index(.native|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx) at ModuleResolver.resolveDependency (/home/lipl-149/Desktop/Ankit/ReactJs/ReactNativeTry/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:114:15) at DependencyGraph.resolveDependency (/home/lipl-149/Desktop/Ankit/ReactJs/ReactNativeTry/node_modules/metro/src/node-haste/DependencyGraph.js:277:43) at /home/lipl-149/Desktop/Ankit/ReactJs/ReactNativeTry/node_modules/metro/src/lib/transformHelpers.js:169:21 at Server._resolveRelativePath (/home/lipl-149/Desktop/Ankit/ReactJs/ReactNativeTry/node_modules/metro/src/Server.js:1045:12) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async Server.requestProcessor [as _processBundleRequest] (/home/lipl-149/Desktop/Ankit/ReactJs/ReactNativeTry/node_modules/metro/src/Server.js:449:37) at async Server._processRequest (/home/lipl-149/Desktop/Ankit/ReactJs/ReactNativeTry/node_modules/metro/src/Server.js:383:7)

To able to do image expression recognition

like image 973
Ankit Dhanotiya Avatar asked Oct 16 '25 16:10

Ankit Dhanotiya


2 Answers

Had the same issue, turns out I had the incorrect configuration on metro.config.js.

You should have a similar configuration as Expo. This is from version 51, but it should work on previous Expo versions.

What I had instead was using the recommended React Native Metro configuration, like so:

const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');

instead of

const { getDefaultConfig } = require('expo/metro-config');

Hope this helps!

like image 74
veryprofessionaldodo Avatar answered Oct 18 '25 07:10

veryprofessionaldodo


I'm using Expo with prebuild to generate my react-native app. I ran into this while upgrading from Expo 48 to Expo 51. It looks like that process had updated the ios/App/AppDelegate.mm file to replace "index" with ".expo/.virtual-metro-entry" in the following code block:

#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@".expo/.virtual-metro-entry"];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif

So I edited the code block back to this:

#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif

This defeats the purpose of prebuild as I'm updating native files, so if someone knows if there's a way to update prebuild to fix this, let me know. (This PR may be useful for research) But I just wanted to get past this problem as I couldn't find another solution. Hopefully this may help you.

like image 41
efeder Avatar answered Oct 18 '25 08:10

efeder