【问题标题】:GraphQL error when launching KeystoneJS application启动 KeystoneJS 应用程序时出现 GraphQL 错误
【发布时间】:2020-05-12 23:38:16
【问题描述】:

我刚刚使用yarn create keystone-app my-app 创建了一个 KeystoneJS。

当我尝试使用 yarn dev 运行它并浏览到它时,我收到以下错误:

Error: Cannot use GraphQLSchema "[object GraphQLSchema]" 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.
    at instanceOf (/my/home/path/my-first-ks-app/node_modules/@keystonejs/keystone/node_modules/graphql/jsutils/instanceOf.js:28:13)
    at isSchema (/my/home/path/my-first-ks-app/node_modules/@keystonejs/keystone/node_modules/graphql/type/schema.js:36:34)
    at assertSchema (/my/home/path/my-first-ks-app/node_modules/@keystonejs/keystone/node_modules/graphql/type/schema.js:40:8)
    at validateSchema (/my/home/path/my-first-ks-app/node_modules/@keystonejs/keystone/node_modules/graphql/type/validate.js:44:28)
    at graphqlImpl (/my/home/path/my-first-ks-app/node_modules/@keystonejs/keystone/node_modules/graphql/graphql.js:79:62)
    at /my/home/path/my-first-ks-app/node_modules/@keystonejs/keystone/node_modules/graphql/graphql.js:28:59
    at new Promise (<anonymous>)
    at graphql (/my/home/path/my-first-ks-app/node_modules/@keystonejs/keystone/node_modules/graphql/graphql.js:26:10)
    at _graphQLQuery.<computed> (/my/home/path/my-first-ks-app/node_modules/@keystonejs/keystone/lib/Keystone/index.js:477:7)
    at Keystone.executeQuery (/my/home/path/my-first-ks-app/node_modules/@keystonejs/keystone/lib/Keystone/index.js:252:14)
    at Object.module.exports [as onConnect] (/my/home/path/my-first-ks-app/initial-data.js:10:22)
    at /my/home/path/my-first-ks-app/node_modules/@keystonejs/keystone/lib/Keystone/index.js:323:35
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async executeDefaultServer (/my/home/path/my-first-ks-app/node_modules/@keystonejs/keystone/bin/utils.js:114:3)
error Command failed with exit code 1.

我使用的是带有 Ubuntu 的 Windows 10 / WSL (v1)。 KeystoneJS 在 Linux 上运行,MongoDB 服务器安装在 Windows 上并运行。这是因为当我让它在 Linux 中运行时,mongod 显示为正在运行并正在侦听,但我无法连接到它(通过 KeystoneJS 或通过 shell 使用 mongo 命令)。

我该如何解决这个问题?

【问题讨论】:

  • 这里有同样的问题。空白的启动项目现在似乎正在运行。

标签: mongodb graphql yarnpkg windows-subsystem-for-linux keystonejs


【解决方案1】:

运行这一行

rm -rf node_modules/@keystonejs/keystone/node_modules/graphql

或将其添加到 Dockerfile 以构建生产映像

【讨论】:

    【解决方案2】:

    当我收到此错误时,我正在使用 graphql@15.0.0

    我通过降级到graphql@14.6.0来修复它。

    我在 apollo 的一个基石项目中遇到了这个问题。

    【讨论】:

      猜你喜欢
      • 2018-11-09
      • 2018-03-26
      • 2017-05-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-06
      • 2020-06-10
      • 1970-01-01
      相关资源
      最近更新 更多