我有一个带有 ApolloClient 和 Apollo-Link-Schema 的 React 应用程序。该应用程序在本地运行良好,但在我们的暂存环境(使用 GOCD)中,我们收到以下错误:
Uncaught Error: Cannot use e "__Schema" 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 t.a (instanceOf.mjs:21)
at C (definition.mjs:37)
at _ (definition.mjs:22)
at X (definition.mjs:284)
at J (definition.mjs:287)
at new Y (definition.mjs:252)
at Y (definition.mjs:254)
at Object.<anonymous> (introspection.mjs:459)
at u (NominationsApprovals.module.js:80)
at Object.<anonymous> (validate.mjs:1)
依赖项是用 yarn 安装的,我已将该resolutions
字段添加到 package.json。
"resolutions": {
"graphql": "^14.5.8"
},
我检查了 yarn.lock 并且只能找到 graphql 包的一个参考。
npm ls graphql
不显示任何重复项。
我认为这可能是 webpack 的构建问题 - 我有一个不同的构建脚本用于暂存,但是在本地运行它我仍然能够让 react 应用程序与该包一起运行。
任何人都可以提出其他建议来帮助我解决这个问题吗?