node.jsreactjsreact-nativenode-modules

While running ReactiNative project index.js not found error occur


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


Solution

  • 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