-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the issue
When I'm trying to build the project I run into the error
Unable to resolve "./RCTNetworking" from "node_modules/react-native/Libraries/Network/XMLHttpRequest.js"
Seems like the issue is node_modules/react-native/Libraries/Network directory has an RCTNetworking.android.js and RCTNetworking.ios.js but the metro.config.js can't find a corresponding file for web.
I have a dependency that makes my API requests with axios (that i access from my npm module / not directly from my app components/stores.
I've tried mocking out the RCTNetworking but can't seem to get anything to work. It will either not make the request or will fail with the same import error.
For instance if I do
if (moduleName.endsWith("RCTNetworking")) {
return {
filePath: require.resolve("identity-obj-proxy"),
type: "sourceFile"
}
}
It hides the error on build but I can't make HTTP calls and gives me the following error when I try to make an API request
TypeError: Cannot read properties of undefined (reading 'default')
at XMLHttpRequest.send (XMLHttpRequest.js:527:7)
at dispatchXhrRequest (xhr.js:195:13)
at tryCallTwo (core.js:45:5)
at doResolve (core.js:200:13)
at new Promise (core.js:66:3)
at xhr (xhr.js:15:10)
at ThrottlingAdapter.<anonymous> (adapter.js:186:40)
at Generator.next (<anonymous>)
at adapter.js:8:71
at tryCallTwo (core.js:45:5)
at Axios.request (Axios.js:45:41)
Expected behavior
Would expect to compile and be able to make API requests.
Steps to reproduce
- npx expo start --web -c
"react-native": "0.74.2",
"expo": "^51.0.0"
Test case
N/A
Additional comments
No response