Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Duplicate "graphql" #1928

Closed
MitkoTschimev opened this issue Feb 17, 2018 · 30 comments
Closed

Duplicate "graphql" #1928

MitkoTschimev opened this issue Feb 17, 2018 · 30 comments

Comments

@MitkoTschimev
Copy link

MitkoTschimev commented Feb 17, 2018

We had this problem inside graphql-yoga too but it was fixed. Now it looks like that we have it in prisma too

Bug Report

Current behavior

Duplicate "graphql" modules cannot be used at the same time since different
versions may have different capabilities and behavior. The data from one
version used in the function from another could produce confusing and
spurious results.
    at instanceOf (/Users/mtschimev/ownCloud/private_workspace/visual-knight/visual-testing-manager/server/prisma/node_modules/graphql/jsutils/instanceOf.js:17:13)
    at isSchema (/Users/mtschimev/ownCloud/private_workspace/visual-knight/visual-testing-manager/server/prisma/node_modules/graphql/type/schema.js:48:35)
    at validateSchema (/Users/mtschimev/ownCloud/private_workspace/visual-knight/visual-testing-manager/server/prisma/node_modules/graphql/type/validate.js:51:25)
    at assertValidSchema (/Users/mtschimev/ownCloud/private_workspace/visual-knight/visual-testing-manager/server/prisma/node_modules/graphql/type/validate.js:76:16)
    at Object.validate (/Users/mtschimev/ownCloud/private_workspace/visual-knight/visual-testing-manager/server/prisma/node_modules/graphql/validation/validate.js:61:35)
    at doRunQuery (/Users/mtschimev/ownCloud/private_workspace/visual-knight/visual-testing-manager/server/prisma/node_modules/apollo-server-core/src/runQuery.ts:143:30)
    at /Users/mtschimev/ownCloud/private_workspace/visual-knight/visual-testing-manager/server/prisma/node_modules/apollo-server-core/src/runQuery.ts:69:39
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7)

Reproduction

Prisma project with following package.json

"dependencies": {
    "bcryptjs": "2.4.3",
    "dotenv": "5.0.0",
    "graphql-yoga": "1.3.2",
    "jsonwebtoken": "8.1.1",
    "prisma-binding": "1.5.12"
  },
  "devDependencies": {
    "@types/bcryptjs": "2.4.1",
    "dotenv-cli": "1.4.0",
    "graphql-cli": "2.14.1",
    "nodemon": "1.14.12",
    "npm-run-all": "4.1.2",
    "prisma": "1.2.3",
    "rimraf": "2.6.2",
    "ts-node": "4.1.0",
    "typescript": "2.6.2"
  }

Expected behavior?
Server is working ;)

@maarteNNNN
Copy link
Contributor

maarteNNNN commented Feb 17, 2018

@tfiwm Here was my issue downgrade your prisma to 1.1.2
After a restart of all services it seemed to work again.

yarn add [email protected]
prisma local nuke
prisma local stop
prisma local start
prisma local deploy
yarn dev

This is in your project not globally.

@marktani
Copy link
Contributor

@tfiwm could you try using the global dependency for prisma instead?

@peterschussheim
Copy link
Contributor

I am getting similar errors:

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

Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.

https://yarnpkg.com/en/docs/selective-version-resolutions

Duplicate "graphql" modules cannot be used at the same time since different
versions may have different capabilities and behavior. The data from one
version used in the function from another could produce confusing and
spurious results.
    at instanceOf (/Users/peter/Sources/Repos/notes/packages/notes-prisma-local/node_modules/graphql/jsutils/instanceOf.js:17:13)
    at isSchema (/Users/peter/Sources/Repos/notes/packages/notes-prisma-local/node_modules/graphql/type/schema.js:48:35)
    at validateSchema (/Users/peter/Sources/Repos/notes/packages/notes-prisma-local/node_modules/graphql/type/validate.js:51:25)
    at assertValidSchema (/Users/peter/Sources/Repos/notes/packages/notes-prisma-local/node_modules/graphql/type/validate.js:76:16)
    at Object.validate (/Users/peter/Sources/Repos/notes/packages/notes-prisma-local/node_modules/graphql/validation/validate.js:61:35)
    at doRunQuery (/Users/peter/Sources/Repos/notes/packages/notes-prisma-local/node_modules/apollo-server-core/src/runQuery.ts:143:30)
    at /Users/peter/Sources/Repos/notes/packages/notes-prisma-local/node_modules/apollo-server-core/src/runQuery.ts:69:39
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7)

Please let me know if you want a new issue for this.

@lirbank
Copy link

lirbank commented Feb 17, 2018

I was trying different setup options for prisma and see the same thing what ever I do (these are fresh installs).

Adding this to package.json solves the issue:

"resolutions": {
  "graphql": "^0.13.1"
}

Update: I am using:

$ prisma --version
prisma/1.2.4 (darwin-x64) node-v9.5.0

@MitkoTschimev
Copy link
Author

@lirbank your solution works for me! Thx ;)

@iamclaytonray
Copy link
Contributor

iamclaytonray commented Feb 18, 2018

For anyone who is using Yarn, this is a known issue between them & graphql. The simple workaround is to rm -rf node_modules && npm i to install with NPM. I'll try to find the issue to link here. Otherwise, this issue can probably be closed since it has nothing to do with GC/Prisma. 😄

Update:

I can't find the issue. I'll try to look more later when I have a bit more time. Cheers

@lirbank
Copy link

lirbank commented Feb 18, 2018

@iamclaytonray Just a heads up before you close this issue - if you have yarn installed on your system and follow the steps here https://www.prismagraphql.com/docs/quickstart/ it happens every time (at least for me). You don't see it if you start fresh?

@iamclaytonray
Copy link
Contributor

iamclaytonray commented Feb 18, 2018

I don't have access to close the issue but despite setting up Prisma a specific way, the issue is between Yarn and graphql

@lirbank - I did use those steps though, as well as going off of memory. I have noticed that it will work with Yarn sometimes, depending on the version of graphql you're using. I'm not 100% sure what's going between the two.

@muhajirdev
Copy link
Contributor

Yeah, seems the trouble was with yarn. @iamclaytonray . Your solution works for me..

@marktani
Copy link
Contributor

Hey @tfiwm @maarteNNNN @peterschussheim @lirbank @iamclaytonray, thanks for chiming in.

Could you please check if following these instructions solves the issue for you?

Thanks! 🙌

@schickling
Copy link
Member

As @lirbank pointed out, add the following to your package.json and run yarn install. This should fix the problem:

  "resolutions": {
    "graphql": "0.13.1"
  }

Please let us know if someone still hits this problem.

@marktani
Copy link
Contributor

For anyone still running into this, upgrading yarn from 0.27.5 to 1.3.2 fixed it for me.

@LawJolla
Copy link

LawJolla commented Apr 4, 2018

And for anyone else fighting this one, I've found this error on port conflicts. If the server didn't properly shut down and still holds the port, restarting the server will throw the port conflict error but will also throw the multiple versions of GraphQL duplicate error, so you may never notice the port error at the very top of the terminal.

To fix it (on a Mac), first find the offending process
lsof -i :<port>
Find the PID and..
kill -9 <pid>

@schickling
Copy link
Member

Quick tip to @LawJolla: Use https://github.com/sindresorhus/fkill-cli to make killing processes by port easier. 💯

@lynnic26
Copy link

lynnic26 commented Jun 5, 2018

"resolutions": { "graphql": "0.13.1" }
adding resolutions works for me

@tomitrescak
Copy link

tomitrescak commented Jul 9, 2018

Wow, I can't believe that the only solution was to use NPM instead of yarn. I tried EVERYTHING, but that was the only thing that helped. Oh well, luckily npm is much faster now.

@tomitrescak
Copy link

Is this considered to be solved? I cannot make it work in any of my applications ;( Only NPM works. Yarn is deaf. I have everything installed properly:

yarn global add graphql-cli graphql prisma-binding

I have following in my package.json

  "resolutions": {
    "graphql": "0.13.2"
  },

Yet still no love ;(

@sscaff1
Copy link

sscaff1 commented Oct 25, 2018

I am still getting this issue. package.json

  "dependencies": {
    "dotenv": "^6.1.0",
    "graphql": "^0.13.2",
    "graphql-cli": "^2.16.7",
    "prisma": "^1.19.0",
    "prisma-binding": "2.1.6"
  },
  "resolutions": {
    "graphql": "^0.13.2"
  }

npm script
"get-schema": "graphql get-schema -p prisma --dotenv variables.env"

I've tried killing every process, uninstalling Yarn, installing everything with NPM. Nothing works. Frustrating...

@iquabius
Copy link

I was getting this error running npx prisma generate. I was able to get around it by using the global prisma: prisma generate.

@iamclaytonray
Copy link
Contributor

iamclaytonray commented Oct 27, 2018

@sscaff1 - try removing ranges & pinning exact deps. You should not actually need a resolutions field. I never actually added that to any of my prisma projects, so that means it's not actually a fix. Try rm -rf node_modules/ && npm i

Looks like my above comment helped everyone else out before so should work for you. What OS are you on and how are you running the server? Locally or docker?

@AviIhej
Copy link

AviIhej commented Nov 10, 2018

I'm having the same problem as her and I'm running Docker. I have tried absolutely everything

@geabenitez
Copy link

rm -rf node_modules && npm i

This worked for me.

@jackgray
Copy link

jackgray commented Jan 28, 2019

What I can't figure out is why this started happening to me since I have not changed any of my dependencies at all. I made changes to my datamodel and that is all. Deleting the modules and reinstalling did not work and searching processes on my port returned nothing.

Update: running prisma generate works, but I don't know if that's really a fix.

Any leads on what's causing deploy to stop working but allowing generate to work? What's the difference, anyway?

@lukel94
Copy link

lukel94 commented Jan 30, 2019

Wow, I can't believe that the only solution was to use NPM instead of yarn. I tried EVERYTHING, but that was the only thing that helped. Oh well, luckily npm is much faster now.

same

@Wgil
Copy link

Wgil commented Feb 12, 2019

Downgrading to:

"prisma: ^1.17.1",
"graphql-cli: "^2.16.7"

solved this issue for me

@jackgray
Copy link

jackgray commented Feb 15, 2019

@Wgil I'm not sure I consider downgrading to pre-prisma-client a solution.. We need to be able to use npm and the latest stable release of prisma imo. Yarn shouldn't be necessary as it is not always up to date with prisma, at least it wasn't the last time I used it, when I was trying to move from 1.17 to 1.18, at which point I had to delete yarn to let npm be prioritized globally. If yarn is required to use prisma without errors, would it be reasonable to state so in the docs?

Edit: perhaps it's more a problem with graphql/npm? I'm not sure but it seems more or less isolated to prisma deploy. I had to restart my whole project as I wasn't able to isolate the problem in effort to ensure sustainability down the road.

@Wgil
Copy link

Wgil commented Feb 17, 2019

@jackgray you're right. By the way, It also worked on npm...

@mszczepanczyk
Copy link

I'm getting this error with 1.34. 1.33 worked fine (npm 6.4.1)

@thehashrocket
Copy link

i solved this by doing npm i -g prisma. I was able to do prisma init after that and deploy.

@KShewengger
Copy link

KShewengger commented Dec 2, 2020

Combining with all the methods specified above.
What worked for me was:

1.) Delete your node_modules and your package-lock.json

$ rm -rf node_modules
$ rm package-lock.json

2.) On your package.json, add this

{
   ...
   "resolutions": {
       "graphql": "^0.13.1"
  },
  "dependencies": {
       ...,
       "graphql": "^0.13.1"
  }
}

3.) Install all dependencies
$ npm install


Current Global versions

Node version: v14.14.0

  • For Prisma 1, it's best to use v12.x.x especially when running prisma init

Prisma version: v1.34.10

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests