gpt4 book ai didi

typescript - ./node_modules/graphql/index.mjs 中的错误 49 :0-53:205 Can't reexport the named export

转载 作者:行者123 更新时间:2023-12-02 07:33:30 24 4
gpt4 key购买 nike

我尝试使用 webpack 4 将基于 typescript 的应用程序构建为 graphql 服务器。

但出现如下错误:

ERROR in ./node_modules/graphql/index.mjs 49:0-53:205
Can't reexport the named export 'BREAK' from non EcmaScript module (only default export is available)
@ ./graphql/schema.ts
@ ./graphql/server.ts

ERROR in ./node_modules/graphql/index.mjs 64:0-98:42
Can't reexport the named export 'BreakingChangeType' from non EcmaScript module (only default export is available)
@ ./graphql/schema.ts
@ ./graphql/server.ts

ERROR in ./node_modules/graphql/index.mjs 36:0-47:50
Can't reexport the named export 'DEFAULT_DEPRECATION_REASON' from non EcmaScript module (only default export is available)
@ ./graphql/schema.ts
@ ./graphql/server.ts

ERROR in ./node_modules/graphql/index.mjs 64:0-98:42
Can't reexport the named export 'DangerousChangeType' from non EcmaScript module (only default export is available)
@ ./graphql/schema.ts
@ ./graphql/server.ts

ERROR in ./node_modules/graphql/index.mjs 49:0-53:205
Can't reexport the named export 'DirectiveLocation' from non EcmaScript module (only default export is available)
@ ./graphql/schema.ts
@ ./graphql/server.ts

ERROR in ./node_modules/graphql/index.mjs 58:0-60:675
Can't reexport the named export 'FieldsOnCorrectTypeRule' from non EcmaScript module (only default export is available)
@ ./graphql/schema.ts
@ ./graphql/server.ts
.....

最佳答案

我今天在使用 Angular Universal SSR 时遇到了完全相同的问题。

我的解决方案是将这一行包含到我的 webpack 配置文件中的 externals 对象中。

externals: {
'./dist/server/main': 'require("./server/main")'
},

对于那些在使用 Angular 8 和 Apollo for Graphql 时遇到同样问题的人来说,这是一份给我带来启发的迁移指南:Angular Universal v8 upgrade guide

关于typescript - ./node_modules/graphql/index.mjs 中的错误 49 :0-53:205 Can't reexport the named export,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54553264/

24 4 0