Search code examples
npmgraphqlgraphql-jsnpm-link

Cannot use GraphQLSchema "[object GraphQLSchema]" from another module or realm when using npm link


I'm using npm link to change my private package and see changes in action in another project. The problem is that both my projects use graphql as a dependency so I get an error Cannot use GraphQLSchema "[object GraphQLSchema]" I was trying to use resolutions key in package.json of my main project. Unfortunately it didn't help. So, I'm clueless about how to resolve this issue without pushing a newer version of my package to npm


Solution

  • To get around this do the following

    1. npm i -g graphql
    2. For each dependant project, inside the working directory
      1. npm link graphql

    This will connect to the globally installed graphql for each project and allow you to share the module without the shared directory structure