关于vite build后访问报错:Expected a JavaScript module script but the server responded with a MIME type.

问题描述:
  • vite 项目 build 部署后在浏览器中访问出现以下报错:

    • 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.
解决方案:

上述问题的原因在于:项目build后没有找到正确的静态资源路径,解决如下

// vite.config.js目录下,修改内容如下:
export default viteConfig = {
    base: '/'
}

原文:https://www.codeleading.com/article/34945983820/

原文地址:https://www.cnblogs.com/fyjz/p/15493706.html