Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

I'm unable to load @apollo/client on a React Native Expo app

$
0
0

I'm trying to load @apollo/client on a React Native Expo app.

And I get this error:

While trying to resolve module @apollo/client from file /Users/andrepena/git/anglio-mobile-rn/screens/dictionary/index.tsx, the package /Users/andrepena/git/anglio-mobile-rn/node_modules/@apollo/client/package.json was successfully found. However, this package itself specifies a main module field that could not be resolved (/Users/andrepena/git/anglio-mobile-rn/node_modules/@apollo/client/main.cjs. Indeed, none of these files exist

Then I searched Stackoverflow and someone suggested adding this to my metro.config.json

const { getDefaultConfig } = require("@expo/metro-config");const defaultConfig = getDefaultConfig(__dirname);defaultConfig.resolver.assetExts.push("cjs");module.exports = defaultConfig;

But now, all imports from @apollo/client simply return undefined.

Example:

import { ApolloClient, InMemoryCache } from "@apollo/client";console.log(ApolloClient); // undefinedconsole.log(InMemoryCache); // undefined

Any suggestion?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>