在基于umi+antdPro开发时,报错Can't import the named export 'stringify' from non EcmaScript module (only default export is available) 如下图

解决方法如下:在chainWebpack添加以下配置项
// /config/config.ts
export default defineConfig({
// ...
chainWebpack(config) {
// ...
config.module
.rule('mjs')
.test(/\.mjs$/)
.include
.add(/node_modules/)
.end()
.type('javascript/auto');
},
})
本文介绍了在使用umi和antdPro开发过程中遇到的错误,即无法导入非ESM模块的特定导出(如stringify)。解决方案是在webpack配置中针对.mjs文件规则,允许包含node_modules并指定默认导出。
6362

被折叠的 条评论
为什么被折叠?



