bug: Failed to load module script: Expected a JavaScript module script

1,002 阅读1分钟

某天突然发现开发环境网页变成空白页面,本地是正常的。

开发环境控制台报错: Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.

项目用的是less module写法+react+vite,但是不知道为什么打包的时候iconfont 文件引入了一个不存在的iconfont.js文件,导致该问题。

解决:没搜到有用信息,之前还发现module写法的样式没有生效,所以摒弃了module写法,直接 import less 文件。