apollo-client icon indicating copy to clipboard operation
apollo-client copied to clipboard

Apollo + Webpack : Uncaught ReferenceError: require is not defined

Open lolo-io opened this issue 2 years ago • 2 comments

I am trying to add Web support to my React Native Application, but whenever I try to import from @apollo/client, i have this error in the console of my browser, and the page is blank : Uncaught ReferenceError: require is not defined

My tsx file :

import * as client from '@apollo/client';
import React from 'react';
import {Text, View} from 'react-native';

const App = () => {
  return (
    <View>
      <Text>Hello</Text>
    </View>
  );
};

export default App;

Is there something special I should do ?

lolo-io avatar Feb 25 '22 19:02 lolo-io

Same error here

HugoGomezSalas avatar Mar 15 '22 21:03 HugoGomezSalas

Any news on this issue, for me the minimal example crashes saying Uncaught ReferenceError: exports is not defined

Saikedo avatar Jul 27 '22 20:07 Saikedo

+1 on this issue

nelsonchen5 avatar Oct 03 '22 18:10 nelsonchen5

Hi all 👋 Can anyone share a runnable reproduction here?

With the Metro bundler, additional configuration is required to implicitly resolve files with .cjs/.mjs extensions (see https://github.com/apollographql/apollo-client/issues/10719). I see Webpack is mentioned in the original issue, and I'd be happy to help resolve this with some more info. Thanks!

alessbell avatar Apr 04 '23 20:04 alessbell

We're closing this issue now but feel free to ping the maintainers or open a new issue if you still need support. Thank you!

github-actions[bot] avatar May 05 '23 05:05 github-actions[bot]

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. For general questions, we recommend using StackOverflow or our discord server.

github-actions[bot] avatar Jun 05 '23 00:06 github-actions[bot]