关于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解决方案

问题描述:
  • 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 文件:
     
     说明:
     base是开发或生产环境服务的公共基础路径。合法的值包括以下几种:
      1.绝对 URL 路径名,例如 /f

更多推荐

关于vite build后访问报错:Expected a JavaScript module script but the server responded w