question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uncaught SyntaxError: Unexpected token <

See original GitHub issue

Got 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:closed
  • Created 4 years ago
  • Reactions:6
  • Comments:44 (15 by maintainers)

github_iconTop GitHub Comments

13reactions
dabit3commented, Aug 16, 2019

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

Screen Shot 2019-08-16 at 1 13 19 PM

10reactions
ghostcommented, Aug 30, 2019

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 send index.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 back 200 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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found