【问题标题】:ERROR in ./node_modules/graphql/index.mjs 49:0-53:205 Can't reexport the named export./node_modules/graphql/index.mjs 中的错误 49:0-53:205 无法重新导出命名导出
【发布时间】:2019-06-30 09:14:14
【问题描述】:

我尝试使用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
..... 

【问题讨论】:

  • 我似乎在 SSR 模式下使用 Apollo Angular 时遇到了同样的问题。 @Edgaras Karka 你设法解决了吗?

标签: typescript webpack graphql webpack-4


【解决方案1】:

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

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

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

对于那些在使用 Angular 8 和 Apollo for Graphql 时遇到同样问题的人,这是一份让我心潮澎湃的迁移指南:Angular Universal v8 upgrade guide

【讨论】:

    猜你喜欢
    • 2019-04-29
    • 2021-05-31
    • 2018-01-20
    • 2022-01-12
    • 2021-12-26
    • 1970-01-01
    • 2021-09-14
    • 2021-05-20
    • 1970-01-01
    相关资源
    最近更新 更多