31

error: bundling failed: Error: Unable to resolve module ./../../react-transform-hmr/lib/index.js from /ReactNative/UsermanagementNav/src/App.js: The module ./../../react-transform-hmr/lib/index.js could not be found from /ReactNative/UsermanagementNav/src/App.js.

I have tried to install react-native-transform-hmr using

npm i react-native-transform-hmr

but it does not solve my issue. i am using react-native 0.57.2 and react 16.5.0

13 Answers 13

34

I got an answer.

Just try:

npm start -- --reset-cache

command, it will work.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, that fixed the issue.
33

This issue only happens when react-native 0.57.2 is installed.

It seems like the Metro Bundler has an issue resolving the paths when started from ./node_modules/react-native/scripts/packager.sh.

Starting the Metro Bundler directly from the project directory works for me. Can someone let me know if it works for them too?

# Clean cache
rm -rf $TMPDIR/react-*; rm -rf $TMPDIR/haste-*; rm -rf $TMPDIR/metro-*; watchman watch-del-all

# Start Metro Bundler directly
react-native start

# Now run `react-native run-android` or `react-native run-ios` in another tab

Source

6 Comments

I am using it in xcode so tell me how can i do it whatever you are saying?
Worked when used react-native start --reset-cache instead of react-native start
Yes you can also try this react-native start --reset-cache
for me running metro bundler directly with --reset-cache have worked, however this issue started when I updated my xcode to Version 10.0 (10A255)/ios12. My RN project was and still in react-native: 0.55.4. Thks for the answer!
This solves the problem when running react-native run-ios in the command line. But it does not help if you want to debug on a real device through Xcode... Any solution?
|
13

try clear cache using this commend .this method was worked for me

react-native start --reset-cache

Comments

7

you need to :

  1. downgrade to react-native "0.57.1"

  2. run :

    npm install @babel/runtime

Comments

6

The work-around below has been confirmed to work on:

"react": "16.5.0",
"react-native": "0.57.2"

Work-around:

# https://github.com/facebook/react-native/issues/21490

# 1) Clean cache
rm -rf $TMPDIR/react-*; rm -rf $TMPDIR/haste-*; rm -rf $TMPDIR/metro-*; watchman watch-del-all

# 2) Open a *NEW* terminal tab and 
#    Start Metro Bundler directly from the project folder using:
react-native start  --reset-cache

# 3) Return to second project folder tab and run
# react-native run-android`
# or
# react-native run-ios`

Comments

4

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

This solution work for me. Only update node_modules\metro\src\reactNativeTransformer.js near line no.130

https://github.com/facebook/metro/commit/e595178fc859263cc2d88de08650d99c52bcc0d9

Comments

3

Here is a fun workaround i discovered . (Running on Windows 10 ) Open 2 Powershell windows . In the first type react-native start --reset-cache In the second go to your folder path and type react-native run-android works like a charm!

Comments

3

This issues has been resolved in React [email protected], so you might want to cosider upgrading to that or later version at this point.

Just make sure you also update React and React test renderer to atleast version "16.6.0-alpha.8af6728". I have also migrated to use [email protected] whitout any issues.

React Native 0.57.3 changelog

NOTE WELL: when you upgrade to this version you NEED to upgrade react and react-test-renderer to version "16.6.0-alpha.8af6728" at least (next version will update to "first class support" for 16.6.0, and it will come soon - but you should be fairly safe using 16.6.0 anyway). Also, please check the Known issues section below, especially if you are using Xcode 10.

Comments

3

First of all, do this :

npm install @babel/runtime

Then run this:

react-native start --reset-cache

and then run this one :

react-native run-android

Comments

2

I was so stuck in this for like 3/4 days. I tried every approach but none fixed my problem. Finally I managed to solve this(for me), the following were my settings:

  • npm -version = 6.4.1
  • node -v = 10.11.0
  • python --version = 2.7.14

Then during command "react-native init MyProject" the version it would install would be "0.57.2" which caused me the problem so the easy way that I came across was during init use

>react-native init --version="0.55.4" MyProject

rather than >react-native init MyProject

It fixed everything for me and loaded the startpage on the installed apk on my device ( I am using a device rather than an emulator)

Hope this helps, I am really new to programming, sorry about my inability to explain this stuff more technical terms.

Best wishes

1 Comment

I have been stuck on this for 3 days too! I tried everything and this is the only solution that worked for me. #node10.11 #npm6.4.1 #python2.7 #windows10 #android8 #androidstudio #androidemulator
2

I had the same issue and for me, the secret sause was:

To Update the react-native-cli with

npm install react-native-cli -g

Then, everything was running and working as expected.

My version is 0.60.5

1 Comment

i have mispelled my secrect sauce. But know it isn't a secret anymore.
2

I resolved by these steps,

- 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

Comments

1

1) change react native version react-native "0.57.2" to "0.57.1" in your package.json 2) run yarn|npm install again. 3) kill all node processes killall node 4) test your app again.

most common reason for the problem can be using a physical device other than an emulator. hope this issue will be fixed in future react versions.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.