React-Native Error : Unable to resolve module ./index from node_modules

66 Views Asked by At

I'm trying to compile a react-native app,when i run npm run react-start-android, i encounter this error :

Error: Unable to resolve module ./index from [project_path]\node_modules/. :
None of these files exist :
 * 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)
 * index\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 ([project_path]\node_modules\metro\src\node_haste\DependencyGraph\ModuleResolution.js:115:15)
at DependencyGraph.resolveDependency ([project_path]\node_modules\metro\src\node-haste\DependencyGraph.js:277:43)
at [project_path]\node_modules\metro\src\lib\transformHelpers.js:169:21
at Server._resolveRelativePath ([project_path]\node_modules\metro\src\Server.js:1045:12)
at async Server.requestProcessor [as _processBundleRequest] ([project_path]\metro\src\Server.js:449:37)
at async Server._processRequest ([project_path]\node_modules\metro\src\Server.js:383:7)

I understand that metro can't find an index file (entry file ?) but i can't understand why metro is trying to find it in /node_modules/. and not in my project root folder (where i am using the command).

What i tried :

  • Running npm start -- --reset-cache : Didn't help

  • Copy+Paste my /index.js file into /node_modules/ : The import App from './App' threw an error and i can't seem to make it work by changing the ./App path.

  • Using this command npx react-native bundle --platform android --dev false react-native bundle --platform android --dev false --entry-file "[project_path]\index.js" --bundle-output '[project_path]/android/app/src/main/assets/index.android.bundle' --assets-dest "[project_path]/android/app/src/main/res" in order to provide the entry-file option

  • Adding entryFile: 'App.tsx' to my metro.config.js

I run out of ideas, if anyone could help op guide me on where to search it would be with great pleasure.

Thank you

0

There are 0 best solutions below