2

I am new to ReactNative I am facing one issue. Please check below log for same. I am facing this issue when trying to run ReactNative project using

react-native run-android

Error Log:

Error: Unable to resolve module ./index from D:\ReactNativeProject\testing\node_modules\react-native\scripts/.: The module ./index could not be found from D:\ReactNativeProject\testing\node_modules\react-native\scripts/.. Indeed, none of these files exist: * D:\ReactNativeProject\testing\node_modules\react-native\scripts\index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx) * D:\ReactNativeProject\testing\node_modules\react-native\scripts\index\index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx) at ModuleResolver.resolveDependency (D:\ReactNativeProject\testing\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:163:15) at ResolutionRequest.resolveDependency (D:\ReactNativeProject\testing\node_modules\metro\src\node-haste\DependencyGraph\ResolutionRequest.js:52:18) at DependencyGraph.resolveDependency (D:\ReactNativeProject\testing\node_modules\metro\src\node-haste\DependencyGraph.js:283:16) at D:\ReactNativeProject\testing\node_modules\metro\src\lib\transformHelpers.js:261:42 at Server. (D:\ReactNativeProject\testing\node_modules\metro\src\Server.js:1038:41) at Generator.next () at asyncGeneratorStep (D:\ReactNativeProject\testing\node_modules\metro\src\Server.js:99:24) at _next (D:\ReactNativeProject\testing\node_modules\metro\src\Server.js:119:9) ::ffff:127.0.0.1 - - [29/Mar/2019:05:12:54 +0000] "GET /index.delta?platform=android&dev=true&minify=false HTTP/1.1" 500 - "-" "okhttp/3.12.1"

What I have done to solve this?

1). I tried below command as I found a solution on Github

react-native start --reset-cache

2). I tried to remove the node-module folder and install it again but still not got success.

React Native Version: 0.59.2

enter image description here

Ramesh R
  • 7,009
  • 4
  • 25
  • 38
Lokesh Desai
  • 2,607
  • 16
  • 28

2 Answers2

5

Goto node_modules\react-native\scripts\launchPackager.bat

// comment this line

node "%~dp0..\cli.js" start 

Add this line

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

After that run your project root cd android && gradlew clean and after run react-native run-android

Subhash Patel
  • 674
  • 7
  • 16
  • Thanks bro it works. U saved my time. I spend lots of time on this. Can u tell me why we made those changes? – Lokesh Desai Mar 29 '19 at 06:56
  • @LokeshDesai I face that problem with this version 0.59.2. Please review this link for open issue https://github.com/facebook/react-native/issues/23908 – Subhash Patel Mar 29 '19 at 07:02
  • yes i also faced issue in 0.59.2. thanks for link. most of people able to solve that using react-native start --reset-cache but in my case it is now working. Anyway thanks for solution. – Lokesh Desai Mar 29 '19 at 07:06
1

run

react-native start -- --reset-cache

then run

react-native run-android

in separate command line window.

This works fine for me.

I also notice people fix it by writing some code in node_modules\react-native\scripts\launchPackager.bat, but writing code in node_modules isn't recommended.