SyntaxError: Unexpected token '<' (HTML served instead of JavaScript)
The browser loaded a .js file but received HTML (an error page or the SPA index.html).
Seen on:
JavaScript
Meaning
The first character of an HTML document is <. Wrong script paths, missing build files and SPA fallbacks returning index.html for every URL cause it.
Common causes
- Script path wrong (relative vs absolute)
- Build file missing → server returns index.html
- Deployed under a sub-path without updating base path
- JSX served without compilation
⚡ Quick fix
- Open the script URL directly in the browser
- Fix the base/public path in the bundler config
- Ensure the build output is deployed
Detailed fix by platform
JavaScript
- Vite: set
base: '/app/'when serving from a sub-folder
How to diagnose
- URL — What does the script URL actually return?
- Build — Do the files exist on the server?
🧠 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