frontend – Duplicate “graphql” modules cannot be used at the same time

Good morning/afternoon stackoverflow. I’m using an npm package called @graphql-codegen/cli to generate type definitions/utilites for my GraphQL schema. Recently, I’ve been encountering an error each time I try to run graphql-codegen command/script. This is the error that I get

"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."
"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."

I’m fairly certain this issue is with my environment, not my project. I attempted to create a brand new project from scratch and still received the same error. Here are the things I’ve tried

  • Reinstalling node_modules
  • Using the resolutions property in package.json
  • Using different versions of the graphql/graphql-cli packages
  • Completely wiping out my global npm packages

I’ve spent the last couple of days attempting to resolve this error, but I’m all out of ideas. Any thoughts or recommendations are much appreciated. Also, below is a link to a codesandbox that contains the relevant files

Read more here: Source link