错误信息
使用 Vite 打包的网页白屏,控制台报错。
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of “text/plain”. Strict MIME type checking is enforced for module scripts per HTML spec.
原因
MIME 的类型错误,一般是本地 windows 下开发会遇到的问题。我就是在Windows 下用 Python 内置的 http.server
打开后遇到的。
解决方案
将打包后的文件部署在正式的服务器环境下(如 Nginx、Apache)。
参考资料
- Vite Issues #6088
更多推荐
【Bug收集箱 · 前端】Vite报错:Failed to load module script: Expected a JavaScript module s
发布评论