react-native: bundling failed: Error: Unable to resolve module /../react-transform-hmr/lib/index.js

Environment

React Native Environment Info: System: OS: macOS 10.14 CPU: x64 Intel® Core™ i5-7360U CPU @ 2.30GHz Memory: 97.71 MB / 8.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 10.11.0 - /usr/local/bin/node Yarn: 1.10.1 - /usr/local/bin/yarn npm: 6.4.1 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman IDEs: Android Studio: 3.1 AI-173.4907809 Xcode: /undefined - /usr/bin/xcodebuild npmPackages: react: 16.5.0 => 16.5.0 react-native: 0.57.2 => 0.57.2 npmGlobalPackages: create-react-native-app: 2.0.2 react-native-cli: 2.0.1

Description

BUNDLE [android, dev] …/…/index.js ░░░░░░░░░░░░░░░░ 0.0% (0/1)::ffff:127.0.0.1 - - [06/Oct/2018:10:44:21 +0000] “GET /index.delta?platform=android&dev=true&minify=false HTTP/1.1” 500 - “-” “okhttp/3.10.0” error: bundling failed: Error: Unable to resolve module ./../react-transform-hmr/lib/index.js from /Users/andrariztyan/MyProject/mobile/myapp/App.js: The module ./../react-transform-hmr/lib/index.js could not be found from /Users/andrariztyan/MyProject/mobile/myapp/App.js. Indeed, none of these files exist:

  • /Users/andrariztyan/MyProject/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)
  • /Users/andrariztyan/MyProject/mobile/react-transform-hmr/lib/index.js/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 (/Users/andrariztyan/MyProject/mobile/myapp/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:209:697) at ResolutionRequest.resolveDependency (/Users/andrariztyan/MyProject/mobile/myapp/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:83:16) at DependencyGraph.resolveDependency (/Users/andrariztyan/MyProject/mobile/myapp/node_modules/metro/src/node-haste/DependencyGraph.js:222:485) at Object.resolve (/Users/andrariztyan/MyProject/mobile/myapp/node_modules/metro/src/lib/transformHelpers.js:149:25) at dependencies.map.result (/Users/andrariztyan/MyProject/mobile/myapp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:316:29) at Array.map (<anonymous>) at resolveDependencies (/Users/andrariztyan/MyProject/mobile/myapp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:312:16) at /Users/andrariztyan/MyProject/mobile/myapp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:169:33 at Generator.next (<anonymous>) at step (/Users/andrariztyan/MyProject/mobile/myapp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:271:307) BUNDLE [android, dev] …/…/index.js ░░░░░░░░░░░░░░░░ 0.0% (0/1), failed.

Reproducible Demo

Let us know how to reproduce the issue. Include a code sample, share a project, or share an app that reproduces the issue using https://snack.expo.io/. Please follow the guidelines for providing a MCVE: https://stackoverflow.com/help/mcve

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 11
  • Comments: 32

Most upvoted comments

Same issue as #21490. There is a workaround which works for now given there.

Thanks @Girish2015 for that. I did react-native start --reset-cache as proposed, and then in another terminal window I did react-native run-ios and Problem Solved.

@anasred . react-native start --reset-cache . woked ~

@anasred . react-native start --reset-cache . woked ~

wow!,thank you guys,it worked now!

react-native start --reset-cache

@anasred thanks!!! ✅ react-native start --reset-cache works for me!!! ✅

Thanks @anasred react-native start --reset-cache works for me.

no one solution above doesn’t work for me. Only one is - run bundler by command react-native start and then hit cmd+R in simulator

UPDATE: THANKS, it worked now. using react-native start and another tab terminal react-native run-android

thanks @anasred It worked for me

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

I have tried all the above mentioned solutions/workarounds but the problem still persists. Is some thing i am missing

Getting below error for react-native start --reset-cache

PS D:\LW_Mobile\Projects\helloworld> react-native start --reset-cache ┌──────────────────────────────────────────────────────────────────────────────┐ │ │ │ Running Metro Bundler on port 8081. │ │ │ │ Keep Metro running while developing on any JS projects. Feel free to │ │ close this tab and run your own Metro instance if you prefer. │ │ │ │ https://github.com/facebook/react-native │ │ │ └──────────────────────────────────────────────────────────────────────────────┘

Looking for JS files in D:\LW_Mobile\Projects\helloworld

warning: the transform cache was reset. Loading dependency graph…events.js:183 throw er; // Unhandled ‘error’ event ^

Error: listen EADDRINUSE :::8081 at Server.setupListenHandle [as _listen2] (net.js:1360:14) at listenInCluster (net.js:1401:12) at Server.listen (net.js:1485:7) at D:\LW_Mobile\Projects\helloworld\node_modules\metro\src\index.js:157:18 at new Promise () at Object. (D:\LW_Mobile\Projects\helloworld\node_modules\metro\src\index.js:156:12) at Generator.next () at step (D:\LW_Mobile\Projects\helloworld\node_modules\metro\src\index.js:47:262) at D:\LW_Mobile\Projects\helloworld\node_modules\metro\src\index.js:47:422 at

Gowtham close all the terminals then run that command again.

New projects will be reported /…/react-transform-hmr/lib/index.js not found. 0.57.2 i’m use react-native-cli