Gatsby: Only one instance of "graphql" in the node_modules directory

Created on 21 Feb 2018  ·  9Comments  ·  Source: gatsbyjs/gatsby

Description

It appears that [email protected] bumps graphql to ^0.13.0, which results in duplicate graphql entries in yarn.lock. Pinning relay-compiler to 1.4.1 keeps graphql at 0.11.7 which results in only one graphql entry in yarn.lock.

Upgrading graphql to 0.13.1 results in this error message during gatsby build:

GraphQL Error There was an error while compiling your site's GraphQL queries.
  TypeError: rule is not a function

Environment

Gatsby version: 1.9.203
Node.js version: v8.7.0
Operating System: macOS 10.13.3

Most helpful comment

1.9.204 is out — lemme know if there's any more trouble.

All 9 comments

Yeah, I just updated everything in one of my projects and the site is now broken with a similar error:

// ...
success onPreExtractQueries — 0.166 s
success update schema — 0.144 s
GraphQL Error There was an error while compiling your site's GraphQL queries.
  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.

success extract queries from components — 0.099 s
success run graphql queries — 0.029 s
//...

Looking through package-lock.json, only relay-compiler seems to rely on a different version of graphql.

Environment

Gatsby version: 1.9.203
Node.js version: v8.7.0
Operating System: macOS 10.13.3

Getting the exact same problem here

Ugh :-( Just put up a PR to pin the relay-compiler version to 1.4.1.

You're the best.

1.9.204 is out — lemme know if there's any more trouble.

Fixed and released within the hour, impressed! 👏

You're the man, @KyleAMathews.

Is there documentation on how to update an existing project?

You can use npm-check to check what packages in your project can be updated.

Install it globally with npm i -g npm-check and then run npm-check -u inside your project folder (and select which packages to update).

If you only want to update gatsby, you can just run npm i gatsby gatsby-cli to bump them to the latest versions.

I left some notes in https://github.com/gatsbyjs/gatsby/pull/5822#issuecomment-395994572 related to this

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dustinhorton picture dustinhorton  ·  3Comments

3CordGuy picture 3CordGuy  ·  3Comments

totsteps picture totsteps  ·  3Comments

benstr picture benstr  ·  3Comments

ferMartz picture ferMartz  ·  3Comments