首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >编译错误与webpack的大量错误

编译错误与webpack的大量错误
EN

Stack Overflow用户
提问于 2022-01-11 15:56:29
回答 2查看 2.2K关注 0票数 4

我收到错误,编译graphql不能工作,因为graphql依赖。

代码语言:javascript
复制
Version: webpack 4.43.0
Time: 69237ms
Built at: 01/12/2021 3:01:04 PM
 35 assets
Entrypoint main = assets/vendors~896.bundle.js assets/page.js

ERROR in ./node_modules/graphql/index.mjs 12:0-65:205
Can't reexport the named export 'BREAK' from non EcmaScript module (only default export is available)
 @ ./node_modules/graphql-tag/lib/index.js
 @ ./node_modules/apollo-boost/lib/bundle.esm.js
 @ ./src/apollo/client.ts
 @ ./src/App.tsx
 @ ./src/client.js

ERROR in ./node_modules/graphql/index.mjs 20:0-87:42
Can't reexport the named export 'SAMPLE' from non EcmaScript module (only default export is available)
 @ ./node_modules/graphql-tag/lib/index.js
 @ ./node_modules/apollo-boost/lib/bundle.esm.js
 @ ./src/apollo/client.ts
 @ ./src/App.tsx
 @ ./src/client.js

ERROR in ./node_modules/graphql/index.mjs 99:0-80:50
Can't reexport the named export 'SAMPLE' from non EcmaScript module (only default export is available)
 @ ./node_modules/graphql-tag/lib/index.js
 @ ./src/apollo/client.ts
 @ ./src/App.tsx
 @ ./src/client.js

错误:无法从非EcmaScript模块重新导出指定的导出“中断”(只有默认导出可用)

还有上百万这样的。

ps。如果你需要更多细节,请告诉我。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-01-30 10:55:30

昨天我也有过同样的问题,我跟踪了这是github的回答,并将'.mjs'添加到了我的configureWebpack扩展中。遵守规则。只需确保出现在.js'之前。因此,基本上您将得到如下内容:

代码语言:javascript
复制
const config = {
 configureWebpack: {
   resolve: { // .mjs comes before .js 
     extensions: ['*', '.mjs', '.js', '.json', '.gql', '.graphql']
   },
   module: {
     rules: [ 
       {
         test: /\.mjs$/,
         include: /node_modules/,
         type: 'javascript/auto'
       },
       // all the other rules
     ]
   }
 }
}

module.exports = config
票数 1
EN

Stack Overflow用户

发布于 2022-01-12 05:45:34

尝试使用require(“module”),或者如果您是这样做的,您应该尝试import("module")。也许这个能帮上忙。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70669718

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档