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
- 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 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026