Can't import the named export 'SetArray' from non EcmaScript module (only default export is available
详细错误日志如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
[Build] [BABEL] Note: The code generator has deoptimised the styling of /data/auto-ci/wspace/node_modules/lodash/lodash.js as it exceeds the max of 500KB. [Build] ./node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs 38:20-28 [Build] Can't import the named export 'SetArray' from non EcmaScript module (only default export is available) [Build] at HarmonyImportSpecifierDependency._getErrors (/data/auto-ci/wspace/node_modules/webpack/lib/dependencies/HarmonyImportSpecifierDependency.js:88:6) [Build] at HarmonyImportSpecifierDependency.getErrors (/data/auto-ci/wspace/node_modules/webpack/lib/dependencies/HarmonyImportSpecifierDependency.js:68:16) [Build] at Compilation.reportDependencyErrorsAndWarnings (/data/auto-ci/wspace/node_modules/webpack/lib/Compilation.js:1463:22) [Build] at /data/auto-ci/wspace/node_modules/webpack/lib/Compilation.js:1258:10 [Build] at AsyncSeriesHook.eval [as callAsync] (eval at create (/data/auto-ci/wspace/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:22:1) [Build] at AsyncSeriesHook.lazyCompileHook (/data/auto-ci/wspace/node_modules/tapable/lib/Hook.js:154:20) [Build] at Compilation.finish (/data/auto-ci/wspace/node_modules/webpack/lib/Compilation.js:1253:28) [Build] at /data/auto-ci/wspace/node_modules/webpack/lib/Compiler.js:672:17 [Build] at _done (eval at create (/data/auto-ci/wspace/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:7:1) [Build] at eval (eval at create (/data/auto-ci/wspace/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:30:22) [Build] at /data/auto-ci/wspace/node_modules/webpack/lib/Compilation.js:1185:12 [Build] at /data/auto-ci/wspace/node_modules/webpack/lib/Compilation.js:1097:9 [Build] at processTicksAndRejections (internal/process/task_queues.js:79:11) [Build] @ ./node_modules/@babel/generator/lib/source-map.js [Build] @ ./node_modules/@babel/generator/lib/index.js
源码分析
经过一番测试大致锁定了报错范围。
直接报错的位置在 @jridgewell/gen-mapping 这个包,这个包在引入@jridgewell/set-array 而上面错误的详细信息也可以看出就是 Can't import the named export 'SetArray' from non EcmaScript module (only default export is available) 大致意思就是无法导出 SetArray 这个模块。
于是github上找到这两个包的源码
1 2
// @jridgewell/gen-maping/dist/gen-mapping.mjs import { SetArray, put } from'@jridgewell/set-array';