Tag Archives: Vite build Error

[Solved] Vite build Error: Expected a JavaScript module script but the server responded with a MIME type.

Problem Description:

After vite project build is deployed, the following error messages appear when accessing in the browser:

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.

Solution:

The reason for the above problem is that the correct static resource path is not found after the project is built. The solution is as follows

// In the vite.config.js directory, modify the following.
export default viteConfig = {
    base: '/'
}