react-apollo
react-apollo copied to clipboard
@apollo/react-hooks tried to access apollo-client
Intended outcome:
A CRA application should compile and run
Actual outcome:
Failed to compile.
/my-path/.yarn/$$virtual/@apollo-react-hooks-virtual-b95e1268e6/0/cache/@apollo-react-hooks-npm-3.1.3-c8e01682c1-2.zip/node_modules/@apollo/react-hooks/lib/react-hooks.esm.js
Module not found: @apollo/react-hooks tried to access apollo-client (a peer dependency) but it isn't provided by its ancestors; this makes the require call ambiguous and unsound.
How to reproduce the issue:
This is using Yarn 2.0.0 berry and in my package.json having the following dependencies:
"dependencies": {
"@apollo/client": "^3.0.0-beta.41",
"@apollo/link-error": "^2.0.0-beta.3",
...
"apollo-client": "^2.6.8",
}
Version
System:
OS: macOS 10.15.3
Binaries:
Node: 13.11.0 - /usr/local/bin/node
Yarn: 2.0.0-rc.30.git.20200322.3bbc8e17 - /usr/local/bin/yarn
npm: 6.13.7 - /usr/local/bin/npm
Browsers:
Chrome: 80.0.3987.149
Firefox: 68.0.1
Safari: 13.0.5
Similar situation - the build artifact react-hooks.cjs.js includes the line:
var _apolloClient = require("apollo-client");
Correcting that to read
var _apolloClient = require("@apollo/client");
as a patch fix unblocks the build in the meantime.
My project package.json does not include apollo-client, only @apollo/client.
I am having the same issue. It seems versions are out of sync?
I had the same issue. In my case it was caused by @apollo/react-hoc. Turned out I had @apollo/[email protected] installed, upgrading it to the latest beta (@apollo/[email protected]), fixed the issue.