metro: Metro won't work on Windows for react native
Repro repo: https://github.com/gengjiawen/react-native/tree/feature/RNTester_start. I am trying to make RNTester work on windows, but I am failing with the following mistake. I tested on mac, it works.
Loading dependency graph, done.
error: bundling failed: Error: Unable to resolve module `AppRegistry` from `D:\Developer\react-native\RNTester\js\RNTesterApp.android.js`: Module `AppRegistry` does not exist in the Haste module map
This might be related to https://github.com/facebook/react-native/issues/4968
To resolve try the following:
1. Clear watchman watches: `watchman watch-del-all`.
2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
3. Reset Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`.
4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`.
at ModuleResolver.resolveDependency (D:\Developer\react-native\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:209:1301)
at ResolutionRequest.resolveDependency (D:\Developer\react-native\node_modules\metro\src\node-haste\DependencyGraph\ResolutionRequest.js:83:16)
at DependencyGraph.resolveDependency (D:\Developer\react-native\node_modules\metro\src\node-haste\DependencyGraph.js:239:485)
at Object.resolve (D:\Developer\react-native\node_modules\metro\src\lib\transformHelpers.js:116:25)
at dependencies.map.result (D:\Developer\react-native\node_modules\metro\src\DeltaBundler\traverseDependencies.js:298:29)
at Array.map (<anonymous>)
at resolveDependencies (D:\Developer\react-native\node_modules\metro\src\DeltaBundler\traverseDependencies.js:294:16)
at D:\Developer\react-native\node_modules\metro\src\DeltaBundler\traverseDependencies.js:159:33
at Generator.next (<anonymous>)
at step (D:\Developer\react-native\node_modules\metro\src\DeltaBundler\traverseDependencies.js:239:307)
BUNDLE [android, dev] RNTester\js/RNTesterApp.android.js ░░░░░░░░░░░░░░░░ 0.0% (0/1), failed.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 11
- Comments: 45 (9 by maintainers)
Links to this issue
Commits related to this issue
- Fix regex paths for Windows Reviewed By: davidaurelio Differential Revision: D8735223 fbshipit-source-id: 646f03a6192699a8f890e19cdcafee1631332251 — committed to facebook/metro by deleted user 6 years ago
I know, many devs prefer macOS or linux. But windows has lots of user too. The repro steps is simple and clear. Please spare some time for this issue.
First of all apologies for the delay answering.
It was hard to debug Windows issues since I didn’t have any Windows machine to be able to reproduce it. Now I got one and I’m working on a fix, which should come very soon
This is what I did and it solved the issue for me:
Create a project
react-native init awesomeproject cd awesomeproject
Remove default version of RN and install v 0.55.4
npm remove --save react-native npm i --save react-native@0.55.4
Remove Metro core (not sure this is needed)
npm remove --save-dev metro metro-core
Remove Babel and install v 2.1.0
npm remove babel-preset-react-native npm i --save babel-preset-react-native@2.1.0
In the “.babelrc” file in the project
change: “presets”: [“module:metro-react-native-babel-preset”] To: “presets”: [“react-native”]
Try to run
react-native run-android
Hope it helps!
John
@kelset In the latest code, the debug mode finally works. But you can’t bundle a release using
gradlew :RNTester:android:app:assembleRelease.👋 thanks for the second confirmation, I’ve spoken with Rafeca and he told me that a colleague of his is on the case, hopefully a fix will be found soon!
Anyway remember that everything is open source so you can try to pinpoint the issue yourself and create test solutions!
This is no longer a problem under 0.57.
We’ve opened a new issue to discuss the whole Windows problem, please keep an eye there: https://github.com/facebook/react-native/issues/20353
Same problem. Unable to resolve module AccessibilityInfo.
Version facebook/react-native: 0.56 OS: Windows 10
Rolled back to 0.55.4 and app is working again. Any prediction to solve the problem?
Try 0.57.3
Folks I think that this got closed via this commit https://github.com/facebook/react-native/commit/3ac86c366c91f8d62f0128057019b94a783b4249
We’ll make sure to cherry pick it into 0.56.1 and release it asap.
@rafeca No, still has issue, please reopen.
+1 @rafeca Just updated to 0.56 and borked. Edit: Rolled back to 0.55.4 and app is working again. Will take a read through this.