Skip to content

Error: Duplicate "graphql" modules #211

@tobkle

Description

@tobkle

After starting with today's version (there is no version tag):

yarn dev

And running a posts query in the playground, I received the following error:

Server is running on http://localhost:4000
Serving playground at http://localhost:3000/playground
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.

Solved it by

  • yarn clean cache
  • npm -rf node_modules
  • added in package.json the "resolutions" section
  • yarn install
{
  "name": "node-advanced",
  "scripts": {
    "start": "nodemon -e js,graphql -x node -r dotenv/config src/index.js",
    "debug": "nodemon -e js,graphql -x node --inspect -r dotenv/config src/index.js",
    "playground": "graphql playground",
    "dev": "npm-run-all --parallel start playground"
  },
  "dependencies": {
    "bcryptjs": "2.4.3",
    "graphql-yoga": "1.3.2",
    "jsonwebtoken": "8.1.1",
    "prisma-binding": "1.5.12"
  },
  "devDependencies": {
    "dotenv": "5.0.0",
    "graphql-cli": "2.14.1",
    "nodemon": "1.15.0",
    "npm-run-all": "4.1.2",
    "prisma": "1.2.4"
  },
  "resolutions": {
    "graphql": "^0.13.0",
    "**/graphql": "^0.13.0"
  }
}

Or is there a better way resolving this error situation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions