0
votes

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
Can you please upload your package.json - Android Team
Updated my package.json - Gowthaman
"babel-preset-react-native" Downgrade this version to this ---> 4.0.0 manually And then delete node modules and do npm install then let me know does it works or not. - Android Team
no again the same error after setting "babel-preset-react-native": "^4.0.0" and i manually deleted the node_modlues folder and ran npm install - Gowthaman

2 Answers

1
votes

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
0
votes

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