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
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
I got an answer.
Just try:
npm start -- --reset-cache
command, it will work.
try clear cache using this commend .this method was worked for me
react-native start --reset-cache
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`
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
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!
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
This issues has been resolved in React Native@0.57.3
, 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 React@16.6.0
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.
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.