React Native support is broken
See original GitHub issueThis code was taken directly from the React Native GraphQL branch in the examples repository (https://github.com/mswjs/examples/tree/examples/gql-react-native/examples/graphql-react-native-apollo). I’ve been unable to get that to work at all for other reasons, so I thought I’d create a new repository using the latest versions of everything to demonstrate the error I’m receiving.
https://github.com/wwdrew/mswjs-react-native-failing
Environment
Name | Version |
---|---|
msw | 0.27.0 |
browser | n/a |
react-native | 0.63.4 |
OS | MacOS 11.2.1 |
Current behavior
Metro crashes with this stack trace:
error: Error: Unable to resolve module os from <obscured>/AnotherTest/node_modules/msw/native/lib/index.js: os could not be found within the project.
If you are sure the module exists, try these steps:
1. Clear watchman watches: watchman watch-del-all
2. Delete node_modules and run yarn install
3. Reset Metro's cache: yarn start --reset-cache
4. Remove the cache: rm -rf /tmp/metro-*
4 |
5 | var XMLHttpRequest = require('node-request-interceptor/lib/interceptors/XMLHttpRequest');
> 6 | var os = require('os');
| ^
7 | var tty = require('tty');
8 | var events_1 = require('events');
9 | var nodeRequestInterceptor = require('node-request-interceptor');
Expected behavior
Expecting the API call to be successful and not crash the bundler.
Screenshots
Issue Analytics
- State:
- Created 3 years ago
- Reactions:7
- Comments:15 (12 by maintainers)
Top Results From Across the Web
React Native support is broken · Issue #39 - GitHub
React native 0.10.0 fixes this problem: process.env.NODE_ENV: This value is defined to be "production" or "development" based on your current ...
Read more >Troubleshooting - React Native
These are some common issues you may run into while setting up React Native. If you encounter something that is not listed here,...
Read more >React Native vs Felgo (Best Alternative to Create Mobile Apps)
With React Native, support for tooling is limited. Commands are run from a terminal and it does not ship with a dedicated IDE...
Read more >React Native Web app made a few months ago suddenly has ...
System theme is broken--only shows the light theme. Whole groups of components, specifically mapped components, vanished from Web and iOS, and ...
Read more >React navigation in react-native v0.60 is broken - Stack Overflow
Yep react-native-gesture-handler needs to migrate to androidX. Try : npm install --save-dev jetifier npx jetify.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve had a bit more time this evening to work on this and have managed to get it working a little further, but with some big caveats.
First of all, in order to import ‘events’ I’ve had to install the ‘events’ package, otherwise it fails trying to load that package. This is only used in StrictEventEmitter, I haven’t tracked down where this is imported so I’m not sure yet how to overcome this one. Since it’s referring to EventEmitter, I’m hoping I can change the import to bring in the RN version rather than going through the events package. If someone out there has any suggestions on this I’d be really happy to hear them.
The next problem is the usage of ‘url’ in the getPublicUrlFromRequest function. Just as a hack I’ve removed the function call to ‘format’ entirely and there are no more runtime errors - result, again! However, the call now fails with a ‘Network request failed’. According to the TS annotations the format function is deprecated anyway and should probably be updated, but that still won’t solve the missing ‘url’ package. Again, not sure how to overcome this one.
I do have some good news though, I’ve added ‘chalk’ to the list of external modules in the rollup config and it’s cleared up the ‘tty’ and ‘os’ imports.
Hopefully someone else out there has some ideas on how to fix these issues?
Really nice work @wwdrew !!