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

Error: Cannot use GraphQLSchema "[object GraphQLSchema]" from another module or realm. #532

Closed
jreeve-nl opened this issue Oct 27, 2020 · 11 comments
Assignees
Labels
type: bug 🐛 Something isn't working

Comments

@jreeve-nl
Copy link

Describe the bug
Attempting to launch the web app results in: "Error: Cannot use GraphQLSchema "[object GraphQLSchema]" from another module or realm."

To Reproduce
npx @vendure/create my-app

Expected behavior
Starts the services.

Environment (please complete the following information):

  • @vendure/core version: 0.16.2
  • Nodejs version. 15.0.1
  • Database (mysql/postgres etc): both SQLite and the SQLite.js

Additional context
It's almost certainly a problem with my environment because no-one else is complaining and also it sounds like some dependency conflict of graphsql module versions. I am clearly not a Node.js person :-)

@jreeve-nl jreeve-nl added the type: bug 🐛 Something isn't working label Oct 27, 2020
@jreeve-nl
Copy link
Author

Oh and if someone can help point out what the problem is then I'll surely submit a patch to the build system to detect this condition or a superclass of this condition.

@michaelbromley
Copy link
Member

I think the root cause of this kind of error is when there are multiple graphql packages in your dependency tree, and those versions don't play well together.

Can you run npm ls graphql and paste the output?

@jreeve-nl
Copy link
Author

jreeve-nl commented Oct 27, 2020

└─┬ @vendure/[email protected]
  ├─┬ @graphql-tools/[email protected]
  │ ├─┬ @graphql-tools/[email protected]
  │ │ └── [email protected] deduped
  │ ├─┬ @graphql-tools/[email protected]
  │ │ └── [email protected] deduped
  │ ├─┬ @graphql-tools/[email protected]
  │ │ ├─┬ @graphql-tools/[email protected]
  │ │ │ └── [email protected] deduped
  │ │ ├─┬ @graphql-tools/[email protected]
  │ │ │ └── [email protected] deduped
  │ │ └── [email protected] deduped
  │ ├─┬ @graphql-tools/[email protected]
  │ │ └── [email protected] deduped
  │ ├─┬ @graphql-tools/[email protected]
  │ │ └── [email protected] deduped
  │ ├─┬ @graphql-tools/[email protected]
  │ │ └── [email protected] deduped
  │ └── [email protected] deduped
  ├─┬ @nestjs/[email protected]
  │ ├─┬ @apollo/[email protected]
  │ │ ├─┬ @apollo/[email protected]
  │ │ │ ├─┬ [email protected]
  │ │ │ │ └── [email protected] deduped invalid
  │ │ │ └── [email protected] invalid
  │ │ ├─┬ [email protected]
  │ │ │ └── [email protected] deduped invalid
  │ │ ├─┬ [email protected]
  │ │ │ └── [email protected] deduped
  │ │ ├─┬ [email protected]
  │ │ │ └── [email protected] deduped
  │ │ ├─┬ [email protected]
  │ │ │ ├─┬ [email protected]
  │ │ │ │ └── [email protected] deduped
  │ │ │ └── [email protected] deduped
  │ │ └── [email protected] invalid
  │ ├─┬ @graphql-tools/[email protected]
  │ │ ├─┬ @graphql-tools/[email protected]
  │ │ │ └── [email protected] deduped
  │ │ ├─┬ @graphql-tools/[email protected]
  │ │ │ └── [email protected] deduped
  │ │ └── [email protected] deduped
  │ ├─┬ [email protected]
  │ │ ├─┬ @types/[email protected]
  │ │ │ └── [email protected] deduped
  │ │ ├─┬ [email protected]
  │ │ │ ├─┬ [email protected]
  │ │ │ │ ├─┬ [email protected]
  │ │ │ │ │ └── [email protected] deduped
  │ │ │ │ └── [email protected] deduped
  │ │ │ └── [email protected] deduped
  │ │ ├─┬ [email protected]
  │ │ │ ├─┬ [email protected]
  │ │ │ │ └── [email protected] deduped
  │ │ │ └── [email protected] deduped
  │ │ ├─┬ [email protected]
  │ │ │ └── [email protected] deduped
  │ │ ├─┬ [email protected]
  │ │ │ ├─┬ [email protected]
  │ │ │ │ ├─┬ [email protected]
  │ │ │ │ │ └── [email protected] deduped
  │ │ │ │ └── [email protected] deduped
  │ │ │ └── [email protected] deduped
  │ │ ├─┬ [email protected]
  │ │ │ └── [email protected] deduped invalid
  │ │ └── [email protected] invalid
  │ └── [email protected] deduped
  ├─┬ [email protected]
  │ ├─┬ [email protected]
  │ │ ├─┬ [email protected]
  │ │ │ └── [email protected] deduped
  │ │ ├─┬ [email protected]
  │ │ │ └── [email protected] deduped
  │ │ ├─┬ [email protected]
  │ │ │ └── [email protected] deduped invalid
  │ │ └── [email protected] deduped
  │ ├─┬ [email protected]
  │ │ └── [email protected] deduped
  │ ├─┬ [email protected]
  │ │ └── [email protected] deduped invalid
  │ ├─┬ [email protected]
  │ │ ├─┬ [email protected]
  │ │ │ └── [email protected] deduped
  │ │ ├─┬ [email protected]
  │ │ │ └── [email protected] deduped
  │ │ └── [email protected] deduped
  │ ├── [email protected] invalid
  │ └─┬ [email protected]
  │   └── [email protected] deduped
  ├─┬ [email protected]
  │ └── [email protected] deduped invalid
  ├─┬ [email protected]
  │ └── [email protected] deduped
  ├─┬ [email protected]
  │ └── [email protected] deduped
  └── [email protected]

npm ERR! code ELSPROBLEMS
npm ERR! invalid: [email protected] /node_modules/apollo-server-express/node_modules/graphql
npm ERR! invalid: [email protected] /node_modules/graphql
npm ERR! invalid: [email protected] /node_modules/@apollo/gateway/node_modules/graphql
npm ERR! invalid: [email protected] /node_modules/apollo-server-core/node_modules/graphql
npm ERR! invalid: [email protected] /node_modules/@apollo/federation/node_modules/graphql

npm ERR! A complete log of this run can be found in:

@michaelbromley
Copy link
Member

Those errors don't look very promising. This might be related to you using Node v15. Could you try with v12 or v14 and see if things work better?

@jreeve-nl
Copy link
Author

jreeve-nl commented Oct 27, 2020 via email

@javib94
Copy link

javib94 commented Dec 8, 2020

I had the same problem, changing Node version to v12 worked for me, I didn't try with v14. Thanks!

@abnemo
Copy link

abnemo commented Feb 10, 2021

Hello guys,

I tried latest v14 on latest MacOS and it worked. After updating to latest npm (v7.5.3) got the above mentioned problem.

Thanks!

@michaelbromley
Copy link
Member

I think this is related to the way npm v7 handles peerDependencies. For now, avoid npm v7, i.e use v6 or yarn.

@megataps
Copy link

I got the same problem on Node v16.0.0 and npm 7.11.1

michaelbromley added a commit that referenced this issue May 26, 2021
Relates to #532
Changes to e2e tests relate to the new handling of bad user input described here:
https://github.com/apollographql/apollo-server/
blob/9267a79b974e397e87ad9ee408b65c46751e4565/CHANGELOG.md#v2230
@michaelbromley
Copy link
Member

This is currently blocked because of an upstream regression in the nestjs/graphql package (nestjs/graphql#1468) which prevents me from updating to the latest version. As a result, installing with npm v7 will result in multiple conflicting versions of the graphql package in the dependency tree, giving the error described above.

As soon as the Nestjs/graphql issue is resolved we can update that package and this issue should also resolve at that point.

@michaelbromley
Copy link
Member

Added a work-around which allows the update of the nestjs/graphql package. This solves the npm v7 issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants