module MIME type 🟨 JavaScript

Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html"

A <script type="module"> or dynamic import got HTML back instead of JavaScript.

Seen on: JavaScript

Meaning

Same root cause as other MIME errors: wrong path, SPA fallback returning index.html, or a deployment under a sub-path without base configured.

Common causes

  • Module path wrong / file missing
  • Base path not configured for sub-folder deploys
  • Server mapping .mjs incorrectly

⚡ Quick fix

  1. Check the URL returns JavaScript
  2. Configure the bundler base/publicPath
  3. Serve .js/.mjs as application/javascript

Detailed fix by platform

JavaScript

  1. Vite: export default { base: '/myapp/' }

How to diagnose

  1. URL — What does it return?
  2. Base — Is the app in a sub-folder?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.