我收到错误,编译graphql不能工作,因为graphql依赖。
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。如果你需要更多细节,请告诉我。
发布于 2022-01-30 10:55:30
昨天我也有过同样的问题,我跟踪了这是github的回答,并将'.mjs'添加到了我的configureWebpack扩展中。遵守规则。只需确保出现在.js'之前。因此,基本上您将得到如下内容:
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发布于 2022-01-12 05:45:34
尝试使用require(“module”),或者如果您是这样做的,您应该尝试import("module")。也许这个能帮上忙。
https://stackoverflow.com/questions/70669718
复制相似问题