Chaibi Alaa
Chaibi Alaa

Reputation: 1386

React Native Error: Unable to resolve module `./index`

I have a newly created application using React Native. The app contains a simple login form and a fetch query, nothing complicated, few css and components.

I tried to implement Facebook, and after a LOOOT of struggle, I stopped receiving Facebook errors, while now, I get this error which makes no sense when I run react-native run-android :

No screen shown, nothing, diretcly this 500 error. I searched all over and over for a solution, I even added the form for Gradle, re-installed all npm packages after rm rf node_modules.. still the same error.

implementation ("com.facebook.react:react-native:0.58.5"){force = true}

enter image description here

Upvotes: 12

Views: 21663

Answers (8)

Muhammad Numan
Muhammad Numan

Reputation: 25353

Solution 1:

react-native start -- --reset-cache

Solution 2:

make metro.config.js file at the root of your project and paste below code

module.exports = {
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: false,
      },
    }),
  },
};

Solution 3: run these commands

rm -rf $TMPDIR/react-*; rm -rf $TMPDIR/haste-*; rm -rf $TMPDIR/metro-*; watchman watch-del-all

# Start Metro Bundler directly
react-native start

Upvotes: 0

Freewalker
Freewalker

Reputation: 7315

I was able to solve this (RN 0.61.2) by adding an index.android.tsx file at the project root (above ./src).

That file just contains:

import "./src/App";

Previously it worked fine with index.tsx in ./src, not sure why it broke as of 0.61.2.

Upvotes: 0

Nkoro Joseph Ahamefula
Nkoro Joseph Ahamefula

Reputation: 530

create a new project with react-native init "projectName" go to "node_modules\react-native\scripts\packager.sh" of the new project you have created. copy it and replace it with the one of the old project which is having issue... This worked for me. I found out it was an upgrade to react-native 0.59.2 that caused it..

Upvotes: 0

Mahmonir Bakhtiyari
Mahmonir Bakhtiyari

Reputation: 605

You can run npm install then react-native upgrade to solve this problem.

Upvotes: 0

THpubs
THpubs

Reputation: 8172

I think this question might be related to Unable to resolve module `./index` So the question is, did you try to run the app before you connected facebook? If it worked before then we might have a different issue. However, it's similar to this bug: https://github.com/facebook/react-native/issues/24112

A fix has been released a few hours ago. Please upgrade to react-native 0.59.2.

react-native upgrade

The full guide on how to upgrade: https://facebook.github.io/react-native/docs/upgrading

Upvotes: 4

ilerik
ilerik

Reputation: 196

Used npm start -- --reset-cache to run Metro Bundler and it worked. Found this solution looking for the answer to the same issue, SO post that helped me.

Upvotes: 18

Gianluca Filitz
Gianluca Filitz

Reputation: 431

Thats an error of your backendserver ... look inside the config and remove the module which can't be found

Upvotes: 1

Ritviz Sharma
Ritviz Sharma

Reputation: 326

It is clearly written in the error

Unable to resolve module ./index from /Applications/XAMPP/xamppfiles/htdocs/projects/jobifier-mobile/.: The module ./index could not be found from /Applications/XAMPP/xamppfiles/htdocs/projects/jobifier-mobile/.. Indeed, none of these files exist

Please check and see if you have given the correct path.

Upvotes: -2

Related Questions