andrew-codes / gatsby-plugin-elasticlunr-search

Gatsby search plugin via elastic lunr client-side search index.
http://gatsby-plugin-search.andrew.codes/
MIT License
88 stars 45 forks source link

Error: duplicate "graphql" modules in Gatsby v2 #22

Open jackdbd opened 6 years ago

jackdbd commented 6 years ago

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",
    "babel-plugin-remove-graphql-queries@2.0.0-alpha.1/**/graphql": "0.10.3"
  }

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

krismorf commented 6 years ago

Gatsby v2 is not supported yet. See #14

DHFW commented 5 years ago

It is supported now, see #14 for more details

calamarico commented 5 years ago

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