module MIME type JavaScript Origin: On your device Last updated 14 Oct 2026

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.

Exact message you may see Failed to load module scriptExpected a JavaScript module scriptStrict MIME type checking is enforced for module scripts
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 not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

App Service Application Error — Azure App Service: ":( Application Error" / container didn’t respond to HTTP pings (Azure)App Service Applicati…ChunkLoadError — ChunkLoadError: Loading chunk 123 failed. (JavaScript)ChunkLoadErrorFailed to find a valid digest in the 'integrity' attribute — Console: Failed to find a valid digest in the 'integrity' attribute for resource … with computed SHA-256 integrity (Browser)Failed to find a vali…FileNotFoundException assembly — Could not load file or assembly 'X, Version=…' or one of its dependencies (.NET)FileNotFoundException…MIME type not executable — Refused to execute script from 'x' because its MIME type ('text/html') is not executable (JavaScript)MIME type not executa…OPcache stale code — PHP still runs old code after deploy (OPcache not reset) (PHP)OPcache stale codeRefused to apply style from — Console: Refused to apply style from 'https://…/style.css' because its MIME type ('text/html') is not a supported stylesheet MIME type (Browser)Refused to apply styl…Service worker registration failed — Console: Failed to register a ServiceWorker: A bad HTTP response code (404) was received when fetching the script (Browser)Service worker regist…module MI…

Explore the map of this error Full error map →

🧠 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.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.