apollo-link-logger
apollo-link-logger copied to clipboard
Module not found: Error: Can't resolve 'react' in non-react environnements(Vue/Node)
I have this error when compiling my Vue app with @apollo/client v3, and latest version from apollo-link-logger
The error comes from here, where you are importing from the entire @apollo/client package, and importing react;
https://github.com/blackxored/apollo-link-logger/blob/73806916280054f6844ce1cc59b21f75b38ea542/src/index.js#L2
Possible fix comes from their docs
import { ApolloLink } from '@apollo/client/core';
Having the same problem here. Although I've been using the apollo-link-logger and a similar apollo link (aws-appsync-auth-link) for a couple of months now, this is somehow breaking just now. In fact, when I look at the history of our ci/cd, it turns out that the apollo-link-logger was still working just ~10 hours ago.
I wonder why this is the case. @victorgarciaesgi's suggestion should do the trick, IMO. We are already using the @apollo/client/core module the exact same way in places of our codebase where react is not present.
This is also the suggested way of doing this according to this issue
@blackxored what do you think? I'd be happy to do an MR for this one, as I think it will make the package more compatible again!
Also note, a clean and simple fix is actually just installing react via npm i react.
I was worried about using it as I thought react to be a large package, but a quick glance over to bundlephobia shows that it is just 7kB minified and 2.8kB minified + gzipped
https://bundlephobia.com/[email protected]
@chegger The source code is rougthly ≃ 70 lines so I forked it and ported it into Typescript and put it locally on my projects to avoid putting react in dependencies
I made a package with your solution if anyone needs it: https://www.npmjs.com/package/apollo-link-logger-no-react
:tada: This issue has been resolved in version 2.0.1 :tada:
The release is available on:
Your semantic-release bot :package::rocket: