-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error: bundling failed: Error: Unable to resolve module ./../react-transform-hmr/lib/index.js
#21490
Comments
Looks like the same issue #21486 |
I am getting the same error/messages with the same reproduction steps. I've tried virtually every possible combination of cache clearing, reinstalling, etc. @mfclarke Possibly, but I believe it's different. OP in #21486 is getting errors for |
i tried also simple to reinstall react-transform-hmr but endet up in the same error. |
getting same error. I tried to put a copy of |
Same here on a brand new react-native init. |
Same error on fresh And when downgrading to [email protected] I get
Any version of react-native working with a fresh start react-native ? |
"0.57.1" is working but after init you have to |
So, did this as well but still getting the same error as you. Though I did get this warning: |
@marksturm 0.57.1 worked indeed 👍Thanks
Then finally I'll keep to this version until |
whether the native version 0.57.2 react is often an error? |
This issue only happens when react-native It seems like the Metro Bundler has an issue resolving the paths when started from 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 |
I did a new init with 0.57.2 , cleaned the cache, started the Metro Bundler and in another terminal ran 'run-android', and that worked. Thanks for the post @idk-whatever But I might stick with 0.57.1 for now. Thank you @marksturm for the workaround. |
@icecreamsandwich I don't know where the Metro Bundler cache is stored on Windows. Can you try |
WOW ! that worked 👍 Thanks ! |
The underlying issue is that This is how I fixed it in the end. I have never used Babel and the file hasn’t been changed in the previous releases so I’ll leave the PR to someone else.
// ...
var path = require('path');
var hmrTransform = 'react-transform-hmr/lib/index.js';
var transformPath = require.resolve(hmrTransform);
module.exports = function (options, filename) {
var filePath = path.resolve(options.projectRoot, path.dirname(filename));
var transform = filename ?
'./' + path.relative(filePath, transformPath) // packager can't handle absolute paths
: hmrTransform;
// ... |
Ok thanks everyone for reporting, we'll look into it. I'm going to lock this issue and re-write the solution by @idk-whatever so that people that end up here can follow them while we work on a fix:
|
Could we have done something in CI to catch this? |
@hramos not sure, because I think that it would be something to be tested on the "Metro CI" side - but not even sure about it, since the issue was about the (BTW new version of Metro landed, if you reinstall your node_modules and check if Metro 0.48 is installed now it should work) |
Environment
Marks-MBP:testpro sturm$ react-native info
React Native Environment Info:
System:
OS: macOS High Sierra 10.13.3
CPU: x64 Intel(R) Core(TM) 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 ()
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 ()
at step (/Users/sturm/Desktop/testpro/node_modules/metro/src/DeltaBundler/traverseDependencies.js:271:307)
The text was updated successfully, but these errors were encountered: