Uncaught SyntaxError: Unexpected token <
See original GitHub issueGot this error in console after running
npm run dev
Logs
Uncaught SyntaxError: Unexpected token <
To Reproduce
"svelte": "^3.0.0"
Node js version
v12.4.0
OS and Browser
Ubuntu 19.04
Chrome: Version 75.0.3770.142 (Official Build) (64-bit)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:44 (15 by maintainers)
Top Results From Across the Web
Uncaught SyntaxError: Unexpected token - javascript
An "unexpected token" is likely some illegal character code. Such a code is likely not to show up when you print to console....
Read more >SyntaxError: Unexpected token - JavaScript - MDN Web Docs
The JavaScript exceptions "unexpected token" occur when a specific language construct was expected, but something else was provided.
Read more >SyntaxError: Unexpected token in JavaScript
The "Uncaught SyntaxError: Unexpected token" occurs for multiple reasons: · The error is also caused if you're making an HTTP request to a...
Read more >Uncaught SyntaxError: Unexpected token < - JavaScript - iDiallo
All it means is that the interpreter is expecting JavaScript or JSON and you are feeding it HTML/XML. If you don't think you...
Read more >How to Fix Uncaught SyntaxError: Unexpected token '{'
The JavaScript exceptions " unexpected token " occur when a specific language construct was expected, but something else was provided.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Had this same issue. Some sort of caching issue I think because when I opened in an incognito window everything just worked. Looking into a solution, assuming it has something to do with rollup?
Update: Setting the cache to disabled in the browser network tab worked for me. Not a long term solution, but works for now. cc @antony @php7webmob
I know the issue is closed, but I thought I’d shed a little light on this as it was discussed on Discord.
The problem occurs because
sirv public --single
decides to sendindex.html
for any route/resource that doesn’t exist in the public directory. You’ll know right away that you have a problem when you are requesting, say, an image and you get back200 text/html
response instead of a 404.The browser will try to parse the
index.html
content as though it were an image (or script in the case of this bug) and barf out. Even worse is that the cache is now polluted with garbage data for that URL and the only way to fix it is to clear the cache or disable the cache completely.Hope that helps… I know it drove me nuts for a while!