react-native: error: bundling failed: Error: Unable to resolve module `./../react-transform-hmr/lib/index.js`
Environment
Marks-MBP:testpro sturm$ react-native info
React Native Environment Info: System: OS: macOS High Sierra 10.13.3 CPU: x64 Intel® Core™ i7-6820HQ CPU @ 2.70GHz Memory: 1.78 GB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 8.3.0 - /usr/local/bin/node Yarn: 1.2.1 - /usr/local/bin/yarn npm: 5.3.0 - /usr/local/bin/npm Watchman: 4.7.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 11.4, macOS 10.13, tvOS 11.4, watchOS 4.3 Android SDK: Build Tools: 26.0.3, 27.0.3 API Levels: 23, 26, 27 IDEs: Android Studio: 3.2 AI-181.5540.7.32.5014246 Xcode: 9.4.1/9F2000 - /usr/bin/xcodebuild npmPackages: react: 16.5.0 => 16.5.0 react-native: 0.57.2 => 0.57.2 npmGlobalPackages: create-react-native-app: 0.0.6 react-native-cli: 2.0.1 react-native-git-upgrade: 0.2.7 react-native-init: 0.6.7 react-native-macos-cli: 2.0.1 react-native-own-bridge: 0.0.3 react-native-rename: 2.1.7
Description
After a fresh init i get this error: error: bundling failed: Error: Unable to resolve module ./../react-transform-hmr/lib/index.js
from /Users/sturm/Desktop/testpro/App.js
Reproducible Demo
react-native init testpro cd testpro react-native run-android
Loading dependency graph, done.
error: bundling failed: Error: Unable to resolve module ./../react-transform-hmr/lib/index.js
from /Users/sturm/Desktop/testpro/App.js
: The module ./../react-transform-hmr/lib/index.js
could not be found from /Users/sturm/Desktop/testpro/App.js
. Indeed, none of these files exist:
/Users/sturm/Desktop/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/sturm/Desktop/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/sturm/Desktop/testpro/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:209:697) at ResolutionRequest.resolveDependency (/Users/sturm/Desktop/testpro/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:83:16) at DependencyGraph.resolveDependency (/Users/sturm/Desktop/testpro/node_modules/metro/src/node-haste/DependencyGraph.js:222:485) at Object.resolve (/Users/sturm/Desktop/testpro/node_modules/metro/src/lib/transformHelpers.js:149:25) at dependencies.map.result (/Users/sturm/Desktop/testpro/node_modules/metro/src/DeltaBundler/traverseDependencies.js:316:29) at Array.map (<anonymous>) at resolveDependencies (/Users/sturm/Desktop/testpro/node_modules/metro/src/DeltaBundler/traverseDependencies.js:312:16) at /Users/sturm/Desktop/testpro/node_modules/metro/src/DeltaBundler/traverseDependencies.js:169:33 at Generator.next (<anonymous>) at step (/Users/sturm/Desktop/testpro/node_modules/metro/src/DeltaBundler/traverseDependencies.js:271:307)
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 16
- Comments: 20 (2 by maintainers)
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?
@icecreamsandwich I don’t know where the Metro Bundler cache is stored on Windows. Can you try
react-native start --reset-cache
“0.57.1” is working but after init you have to npm install @babel/runtime
@marksturm 0.57.1 worked indeed 👍Thanks @mathewmorris I still had to
rm -rf node_modules
rm -rf $TMPDIR/react-* && watchman watch-del-all"
yarn install
Then finally
react-native run-android
worked.I’ll keep to this version until
0.57.2
get fixed