[Solved] Vite Error: Failed to load module script: Expected a JavaScript module script but the server…

Error message

Use the white screen of the web page packaged by vite, and the console reports an error.

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.

reason

MIME type errors are generally a problem with native windows development. I encountered this after opening it with Python’s built-in http.server on Windows.

Solution

Deploy the packaged files in a formal server environment (such as nginx and Apache)

Read More: