Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined Unable to resolve module ../version.js from ...\node_modules\@apollo\client\core\ApolloClient.js #11629

Closed
arthy89 opened this issue Feb 28, 2024 · 5 comments

Comments

@arthy89
Copy link

arthy89 commented Feb 28, 2024

I'm having trouble importing Apollo Client into my React Native project.
import { ApolloClient, InMemoryCache, ApolloProvider } from "@apollo/client";

This is the error it shows me in the console:

Unable to resolve "../version.js" from "node_modules\@apollo\client\core\ApolloClient.js" ERROR [Error: undefined Unable to resolve module ../version.js from ***\node_modules\@apollo\client\core\ApolloClient.js:

None of these files exist:
  * node_modules\@apollo\client\version.js(.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.mjs|.native.mjs|.mjs|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.cjs|.native.cjs|.cjs|.android.scss|.native.scss|.scss|.android.sass|.native.sass|.sass|.android.css|.native.css|.css)
  * node_modules\@apollo\client\version.js\index(.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.mjs|.native.mjs|.mjs|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.cjs|.native.cjs|.cjs|.android.scss|.native.scss|.scss|.android.sass|.native.sass|.sass|.android.css|.native.css|.css)
  2 | import { invariant, newInvariantError } from "../utilities/globals/index.js";
  3 | import { ApolloLink, execute } from "../link/core/index.js";
> 4 | import { version } from "../version.js";
    |                          ^
  5 | import { HttpLink } from "../link/http/index.js";
  6 | import { QueryManager } from "./QueryManager.js";
  7 | import { LocalState } from "./LocalState.js";]

In the ApolloClient.js file when searching for the file import { version } from "../version.js"; redirects to "version.d.ts":

export declare const version = "local";
//# sourceMappingURL=version.d.ts.map

But if the "version.js" file exists:

export var version = "3.9.5";
//# sourceMappingURL=version.js.map

I appreciate the help and time to resolve this error.

@phryneas
Copy link
Member

It seems like your bundler is looking for a version.js.js by appending another level of .js there.
We have not encountered anything like this with React Native before - did you change your bundler configuration in your project in any way?

@arthy89
Copy link
Author

arthy89 commented Feb 28, 2024

@phryneas I was installing React Navigation and Nativewind dependencies for the latter to install Apollo Client. I think the problem was in the order of the installation, I started again from the beginning installing Apollo and the following ones and now it no longer shows me any errors. Thanks for help and time.

@phryneas
Copy link
Member

That's great to hear! :)

I'm going to close this issue now - have a great day!

Copy link
Contributor

Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better.

Copy link
Contributor

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 github-actions bot locked as resolved and limited conversation to collaborators Mar 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants