I'm running into an error after installing Apollo when trying to run my React Native Expo app. I've tried deleting node-modules and re-installing, resetting cache, restarting computer, and still no luck. Does anyone have any ideas? Thank you!
Android Bundling failed 456ms While trying to resolve module
@apollo/client
from file >/mnt/c/Users/14044/Desktop/Coding/divii/client/App.tsx
, the package >/mnt/c/Users/14044/Desktop/Coding/divii/client/node_modules/@apollo/client/package.json
>was successfully found. However, this package itself specifies amain
module field that >could not be resolved >(/mnt/c/Users/14044/Desktop/Coding/divii/client/node_modules/@apollo/client/main.cjs
. Indeed, none of these files exist:
- /mnt/c/Users/14044/Desktop/Coding/divii/client/node_modules/@apollo/client/main.cjs(.native|.android.jsx|.native.jsx|.jsx|.android.js|.native.js|.js|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.json|.native.json|.json)
- /mnt/c/Users/14044/Desktop/Coding/divii/client/node_modules/@apollo/client/main.cjs/index(.native|.android.jsx|.native.jsx|.jsx|.android.js|.native.js|.js|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.json|.native.json|.json)
CodePudding user response:
Try downgrading to @apollo/client
3.4.16
. I just did a round of package updates and the 3.5.4
broke my build as well. I'm using the downgraded package with a downgraded version of graphql
lib as well -- 15.7.2
.
Those are the last versions that worked for me with the current version of Expo / RN.
Hope that helps you out!
CodePudding user response:
This is a conflict between @apollo/client v3.5.4 and RN metro bundler.
As a workaround until this issue is resolved, you can configure Metro by creating a metro.config.js file in the root of your React Native project with following content:
const { getDefaultConfig } = require("metro-config");
const { resolver: defaultResolver } = getDefaultConfig.getDefaultValues();
exports.resolver = {
...defaultResolver,
sourceExts: [
...defaultResolver.sourceExts,
"cjs",
],
};
CodePudding user response:
Tried the above solution but it did not work