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.
Failed to load module scriptExpected a JavaScript module scriptStrict MIME type checking is enforced for module scripts 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
- Check the URL returns JavaScript
- Configure the bundler base/publicPath
- Serve .js/.mjs as application/javascript
Detailed fix by platform
JavaScript
- Vite:
export default { base: '/myapp/' }
How to diagnose
- URL — What does it return?
- 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:
Similar errors
- App Service Application Error Azure App Service: ":( Application Error" / container didn’t respond to HTTP pings
- ChunkLoadError ChunkLoadError: Loading chunk 123 failed.
- Failed 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
Most viewed in JavaScript
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 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.
Report a correction or suggest an improvement
Last updated 14 Oct 2026