question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

app crash after apollo client update

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
6ewiscommented, 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
0reactions
6ewiscommented, May 26, 2022

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Odyssey Lift-Off Part 5: Application Error When Deploying ...
Hi,. I followed the tutorial up until the step to deploy the client. My production server is running and I'm able to query...
Read more >
Using @apollo/react-hooks, the react app crashes hard on ...
It seems to get stuck in this error loop when create-react-app is restarted. reactjs · react-apollo · react-apollo-hooks · Share.
Read more >
Apollo for Reddit crashing on Mac M1 after latest update
The application is having multiple crashes since the arrival of its latest updates. Apollo client is one of the most successful to browse ......
Read more >
Build: Updating your cache with Apollo Client - YouTube
Janessa and Trevor take us through updating the cache with Apollo Client in this instalment of Apollo's BUILD series.
Read more >
Handling Errors with Apollo Client (React) - YouTube
In this video I talk about handling errors when running queries and mutations using Apollo Client in a React project.Table of contents:00:00 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found