Getting the following error on running react native app in android emulator

react-native run-android

Loading dependency graph, done. error: bundling failed: Error: Unable to resolve module ./../../react-transform-hmr/lib/index.js from D:\LW_Mobile\Projects\helloworld\App.js: The module ./../../react-transform-hmr/lib/index.js could not be found from D:\LW_Mobile\Projects\helloworld\App.js. Indeed, none of these files exist: * D:\LW_Mobile\react-transform-hmr\lib\index.js(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)

My Package.Json is

{
  "name": "helloworld",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "@babel/runtime": "^7.1.2",
    "babel-preset-react-native": "^4.0.1",
    "react": "16.5.0",
    "react-native": "0.57.2"
  },
  "devDependencies": {
    "babel-jest": "23.6.0",
    "babel-plugin-functional-hmr": "^1.0.24",
    "babel-plugin-react-transform": "^3.0.0",
    "jest": "23.6.0",
    "metro-react-native-babel-preset": "0.48.0",
    "react-test-renderer": "16.5.0",
    "react-transform-hmr": "^1.0.4"
  },
  "jest": {
    "preset": "react-native"
  }
}

The babelrc is as following

{
    "presets": ["es2015", "react", "module:metro-react-native-babel-preset"]
  }

Note: working with expo is launching fine, This is the first time i am using the react-native run-android command

The System is looking into some different path and not within Node_Module. Is something related to this.?

2

There are 2 best solutions below

0
On BEST ANSWER

Found the solution after lot of struggles.

  1. Update all the packages such as Node and react native cli
  2. In Android studio install intel X86 Atom System Image, intel X86 Atom_64 System Image
  3. Close all the npm Terminal
  4. Open a new Command prompt and run react-native start --reset-cache
  5. Open a new Command prompt and run react-native run-android
0
On

you can fix it by using these steps:

  1. Close open all terminal or cmd.

  2. replace dependency in package.json

    "react": "16.5.0" , "react-native": "0.57.1"

  3. execute this command.

    1. npm install @babel/runtime
    2. react-native start --reset-cache
    3. npm install
    4. react-native run-android