gatsby-plugin-elasticlunr-search icon indicating copy to clipboard operation
gatsby-plugin-elasticlunr-search copied to clipboard

Error: duplicate "graphql" modules in Gatsby v2

Open jackdbd opened this issue 5 years ago • 3 comments

I was trying to configure this plugin in a Gatsby v2 website and received this message:

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.

And then...

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.

Error: Cannot use GraphQLObjectType "SitePageConnection" 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.

Here is what I did:

  1. Created a new Gatsby website, starting from the official blog v2 template
gatsby new my-blog https://github.com/gatsbyjs/gatsby-starter-blog#v2
  1. Created a Search React component and copy-pasted the code available in the Consuming your site section.

  2. Updated gatsby-config.js as explained here.

I'm not sure how to use the selective version resolution. In the documentation they say to add a resolutions field in package.json and then run npm install. This is what I tried (with no luck).

"resolutions": {
    "@andrew-codes/**/graphql": "0.13.0",
    "[email protected]/**/graphql": "0.10.3"
  }

Have I misunderstood how to use this plugin or this behavior is due to changes in Gatsby v2?

jackdbd avatar Sep 04 '18 21:09 jackdbd

Gatsby v2 is not supported yet. See #14

krismorf avatar Sep 05 '18 00:09 krismorf

It is supported now, see #14 for more details

DHFW avatar Jan 21 '19 16:01 DHFW

@DHFW Will be supported when merge right? ... Ok I see the publish npm install --save @gatsby-contrib/gatsby-plugin-elasticlunr-search perfect!

calamarico avatar Jan 22 '19 19:01 calamarico