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 amain
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 said I should add 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
In fact, @apollo/client
is exporting this object:
Object {"default": 17,}
Any suggestion?