0

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.?

Gowthaman
  • 790
  • 1
  • 10
  • 29
  • Can you please upload your package.json –  Oct 06 '18 at 12:32
  • Updated my package.json – Gowthaman Oct 06 '18 at 12:46
  • "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. –  Oct 06 '18 at 12:48
  • 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 Oct 06 '18 at 13:01
  • https://stackoverflow.com/questions/45760731/transformerror-with-babel-preset-react-native-index-js?answertab=votes#tab-top Refer this answer –  Oct 06 '18 at 13:16
  • Thank you, I have tried as mentioned in the link, I dosen't help, getting the same error – Gowthaman Oct 06 '18 at 13:45
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/181400/discussion-between-gowthaman-and-android-team). – Gowthaman Oct 06 '18 at 14:03

2 Answers2

1

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

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
Gowthaman
  • 790
  • 1
  • 10
  • 29