xiaochengzi6 / Blog

个人博客
GNU Lesser General Public License v2.1
0 stars 0 forks source link

webpck 打包时候 抛出 '*.mjs' file, or a '*.js' 的错误 #47

Open xiaochengzi6 opened 2 years ago

xiaochengzi6 commented 2 years ago

BREAKING CHANGE: The request '/这里是什么无所谓/' failed to resolve only because it was resolved as fully specified (probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '.mjs' file, or a '.js' file where the package.json contains '"type": "module"').

主要是代码是这样的应用的 import xx from 'xx'没有文件后缀名没有出现的错误

相关的讨论在这里

解决方法

{
  test: /\.m?js/,
  resolve: {
    fullySpecified: false
  }
}