首页 > 解决方案 > 无法使用 GraphQLNonNull“[用户]!” 从另一个模块或领域

问题描述

我知道这个问题被问了很多,但现有的答案对我没有帮助。每当我尝试启动服务器时,都会收到此错误:

[nodemon] 2.0.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,graphql
[nodemon] starting `babel-node src/index.js`
The server is up!
Error: Cannot use GraphQLNonNull "[User]!" 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 (/Users/yildirim/Desktop/backend/node_modules/graphql-binding/node_modules/graphql/jsutils/instanceOf.js:28:13)
    at isNonNullType (/Users/yildirim/Desktop/backend/node_modules/graphql-binding/node_modules/graphql/type/definition.js:194:34)
    at isWrappingType (/Users/yildirim/Desktop/backend/node_modules/graphql-binding/node_modules/graphql/type/definition.js:364:30)
    at Object.getNamedType (/Users/yildirim/Desktop/backend/node_modules/graphql-binding/node_modules/graphql/type/definition.js:423:12)
    at buildInfoFromFragment (/Users/yildirim/Desktop/backend/node_modules/graphql-binding/src/info.ts:105:21)
    at Object.buildInfo (/Users/yildirim/Desktop/backend/node_modules/graphql-binding/src/info.ts:36:12)
    at Prisma.Delegate.delegateToSchema (/Users/yildirim/Desktop/backend/node_modules/graphql-binding/src/Delegate.ts:159:18)
    at Prisma.<anonymous> (/Users/yildirim/Desktop/backend/node_modules/graphql-binding/src/Delegate.ts:65:17)
    at step (/Users/yildirim/Desktop/backend/node_modules/graphql-binding/dist/Delegate.js:32:23)
    at Object.next (/Users/yildirim/Desktop/backend/node_modules/graphql-binding/dist/Delegate.js:13:53)

将“决议”写入“package.json”文件也对我没有帮助。所以这听起来像是一个版本冲突问题。

这是我的 package.json 文件:

{
  "name": "backend",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "nodemon src/index.js --ext js,graphql --exec babel-node",
    "test": "echo \"Error: no test specified\" && exit 1",
    "get-schema": "graphql-codegen --config codegen.yml"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@graphql-codegen/cli": "1.17.8",
    "nodemon": "^2.0.4",
    "@graphql-codegen/typescript-document-nodes": "1.17.8",
    "@graphql-codegen/introspection": "1.17.8"
  },
  "dependencies": {
    "@graphql-codegen/schema-ast": "^1.17.8",
    "babel-cli": "^6.26.0",
    "babel-plugin-transform-object-rest-spread": "^6.26.0",
    "babel-preset-env": "^1.7.0",
    "core-util-is": "^1.0.2",
    "graphql-cli": "^4.0.0",
    "graphql-tools": "^6.2.3",
    "graphql-yoga": "^1.18.3",
    "prisma-binding": "^2.3.16",
    "uuid": "^8.3.0"
  }
}

我真的不知道如何继续。谁能帮我?提前致谢!:)

标签: node.jsnpmgraphqlbackendprisma

解决方案


推荐阅读