I just created a new React Native project with the latest React Native version 0.59. Unfortunately, I stuck on a new react native error when I try to run the project using the command react-native run-android.
Here’s the React native error fix for 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.
There are three solutions
Solution 1:
1. Run the command react-native start — –reset-cache
2. Open another terminal and run
Solution 2:
Update node_modules\react-native\scripts\launchPackager.bat file as given below.
@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
Solution 3:
Modify \node_modules\@react-native-community\cli\build\commands\runAndroid\runAndroid.js file as given below.
const procConfig = {
// delete this line
cwd: scriptsDir
// add this line
cwd: process.cwd()
};
I hope any of the solutions will solve your React Native issue. If the issue still persists, then refer this GitHub issue.