Md.Moinul Huq
Md.Moinul Huq

Reputation: 3

Error: Unable to resolve module `./index` from `\node_modules\react-native\scripts/.`

I am getting this error when upgrade my react native.

It says

Error: Unable to resolve module ./index from \node_modules\react-native\scripts/.: The module ./index could not be found from \node_modules\react-native\scripts/.. Indeed, none of these files exist:

Actually don't know how to solve. Can anyone help please. Thanks

The version I am currently using

"react": "^16.8.4", "react-native": "^0.59.0",

Upvotes: 0

Views: 2787

Answers (4)

Abhishek Luthra
Abhishek Luthra

Reputation: 2665

Same exact problem I am facing too. I just updated to 0.59.1 and this isn't working... As a work around, I am running the metro builder in a separate tab, and then running react in a separate tab.

react-native start --reset-cache in one terminal and left it open react-native run-android in another terminal

Upvotes: 0

Meraj Khan
Meraj Khan

Reputation: 49

This is an issue in the latest upgrade of react-native version. Please downgrade your current it will work. I tried the same

Upvotes: 0

Nkoro Joseph Ahamefula
Nkoro Joseph Ahamefula

Reputation: 530

This linked solved my problem.

Though you will need to do this for every time you start a new project.. its an upgrade issue from react-native

Update node_modules\react-native\scripts\launchPackager.bat file. @echo off title Metro Bundler call .packager.bat

// delete this line
node "%~dp0..\cli.js" start 

Add this line
node "%~dp0..\cli.js" start --projectRoot ../../../ 

pause
exit

We are giving project root path to Metro instance here,

Or in \node_modules@react-native-community\cli\build\commands\runAndroid\runAndroid.js edit this, const procConfig = {

    // delete this line    
    cwd: scriptsDir

    // add this line
    cwd: process.cwd()
};

Upvotes: 1

Navneet kumar
Navneet kumar

Reputation: 1964

Try removing everything from node_modules and then do npm install

cd node_modules
rm -rf *

cd ../
npm install 

Upvotes: 0

Related Questions