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.

apollo-client require `react` ??

See original GitHub issue

I got this error when compiling with WebPack 5. I’m using vue, does this mean the apollo-client require react as a dependency?

 error  in ./node_modules/@apollo/client/react/context/ApolloConsumer.js

Module not found: Error: Can't resolve 'react' in '/Users/x/node_modules/@apollo/client/react/context'

 error  in ./node_modules/@apollo/client/react/hooks/useApolloClient.js

Module not found: Error: Can't resolve 'react' in '/Users/x/node_modules/@apollo/client/react/hooks'

 error  in ./node_modules/@apollo/client/react/hooks/utils/useBaseQuery.js

Module not found: Error: Can't resolve 'react' in '/Users/x/node_modules/@apollo/client/react/hooks/utils'

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:25
  • Comments:18 (1 by maintainers)

github_iconTop GitHub Comments

211reactions
cmd-johnsoncommented, Nov 26, 2020

I just stumbled across that same problem, but I got the client to work without having to install react. Just import everything you need from @apollo/client/core instead of @apollo/client and you’ll be good to go.

It’d be nice to have that documented somewhere, though.

32reactions
Yohandahcommented, Dec 21, 2020

I’m having this issue as well using @apollo/client in my Angular project.

Importing from @apollo/client/core fixes the problem but I’m unsure why … I think Apollo shouldn’t rely on react since it’s an optional peer dependency

Read more comments on GitHub >

github_iconTop Results From Across the Web

Get started with Apollo Client - Apollo GraphQL Docs
Applications that use Apollo Client require two top-level dependencies: ... If you're using a React sandbox from CodeSandbox and you encounter a TypeError...
Read more >
Understanding Client-Side GraphQl With Apollo-Client In ...
The useMutation React hook is the primary API for executing mutations in an Apollo application. When we need to mutate data, we call...
Read more >
apollo/client - npm
Apollo Client is a fully-featured caching GraphQL client with integrations for React, Angular, and more. It allows you to easily build UI ...
Read more >
Getting Started With Apollo Client in Your React App
You can integrate Apollo Client into any React project and use it along with an existing GraphQL server. If you would like, you...
Read more >
Set up a GraphQL client with Apollo - react - Hasura
Create Apollo Client Instance ... );. };. export default App;. These are the required apollo dependencies to get started. Now let's define a...
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