Skip to content
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

app crash after apollo client update #9731

Open
AlexandrBol opened this issue May 16, 2022 · 7 comments
Open

app crash after apollo client update #9731

AlexandrBol opened this issue May 16, 2022 · 7 comments
Assignees

Comments

@AlexandrBol
Copy link

AlexandrBol commented May 16, 2022

After updatig @apollo/client from version 3.4.14 to version 3.6.2 I got this error

Metro has encountered an error: While trying to resolve module `@apollo/client` from file `my-path/App.tsx`, the package `my-path/node_modules/@apollo/client/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`my-path/node_modules/@apollo/client/main.cjs`. Indeed, none of these files exist:

  * /my-path/node_modules/@apollo/client/main.cjs(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)
  * my-path/node_modules/@apollo/client/main.cjs/index(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx): /my-path/node_modules/metro/src/node-haste/DependencyGraph.js (243:17)

  241 | 
  242 |         if (error instanceof InvalidPackageError) {
> 243 |           throw new PackageResolutionError({
      |                 ^
  244 |             packageError: error,
  245 |             originModulePath: from,
  246 |             targetModuleName: to,

RCTFatal
__28-[RCTCxxBridge handleError:]_block_invoke
_dispatch_call_block_and_release
_dispatch_client_callout
_dispatch_main_queue_drain
_dispatch_main_queue_callback_4CF
__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
__CFRunLoopRun
CFRunLoopRunSpecific
GSEventRunModal
-[UIApplication _run]
UIApplicationMain
main
start_sim
0x0

I was trying to update metro config with:

/**
 * Metro configuration for React Native
 * https://github.com/facebook/react-native
 *
 * @format
 */
const {getDefaultConfig} = require('metro-config');
const {resolver: defaultResolver} = getDefaultConfig.getDefaultValues();

module.exports = {
  resolver: {
    ...defaultResolver,
    sourceExts: [...defaultResolver.sourceExts, 'cjs'],
  },
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: true,
      },
    }),
  },
};

but got no success

@benjamn
Copy link
Member

benjamn commented May 16, 2022

@AlexandrBol Can you try npm i @apollo/client@beta to find out if #9716 solves this problem for you?

@AlexandrBol
Copy link
Author

@benjamn after using @apollo/client@beta got this error on app open
image

@benjamn
Copy link
Member

benjamn commented May 17, 2022

@AlexandrBol That's at least a different (runtime) problem, so we're making progress!

@benjamn
Copy link
Member

benjamn commented May 17, 2022

What versions of react/react-dom and react-native are you using? I ask because I don't think React Native is yet compatible with React 18, in case you tried upgrading.

@6ewis
Copy link

6ewis commented May 19, 2022

He is using the following: @benjamn

    "react-native": "0.68.0",
   "@apollo/client": "3.4.14",
    "@apollo/react-hooks": "^4.0.0",
    "react": "18.0.0", // so that is the culprit

@AlexandrBol
Copy link
Author

AlexandrBol commented May 24, 2022

@benjamn @6ewis
So, I tested once again

    "react": "18.0.0",
    "react-native": "0.68.0",

with
"@apollo/client": "3.4.14",
all working pretty good, but with
"@apollo/client": "^3.7.0-alpha.6" - no

I was trying to add react-dom (test that all works good) and then add
"@apollo/client": "^3.7.0-alpha.6" - got no result still same issue as

image

Upd:
So, I mean that the trouble not is in the react/react-native/react-dom. Trouble inside lib

@6ewis
Copy link

6ewis commented May 26, 2022

@benjamn it seems that react 18 is now compatible with react native. So the issue might be somewhere else

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants