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 <" when refreshing page

See original GitHub issue

Whenever I do a normal refresh, i get these error messages:

manifest.48cbf0211cc2b417df60.js:1    Uncaught SyntaxError: Unexpected token <
vendor.e73f0cf5e42d1a1bdeee.js:1    Uncaught SyntaxError: Unexpected token <
app.d644989e00d1de883ada.js:1    Uncaught SyntaxError: Unexpected token <

When looking in the Network tab, it´s like the entire HTML document (index.html) is being returned instead of the js file. https://imgur.com/a/6AR5P

I’m assuming this has to do with the src to the js-files are returning 404. Question is why though?

If I hit hard refresh (Ctrl + F5), the site loads fine.

Does anyone have any clues?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:18
  • Comments:30

github_iconTop GitHub Comments

163reactions
jainshravan123commented, Aug 9, 2021

See this guys https://github.com/webpack/webpack/issues/2882#issuecomment-280906981

You just need to add <base href="/" /> into the <head> of your index.html. This resolved my problem. It may help you too.

Thanks

9reactions
Dindukscommented, Feb 25, 2020

I get the same issue but not on every refresh, only sometimes after I deploy the app.

From what I understand, the first time I open the app it tries to load a JS files from the previous version (e.g. chunk-9a00505e.02e15df7.js), which doesn’t exist anymore, and which serves a 404 HTML page (that obviously starts with <).

A refresh fixes this, except on progressive web apps on Safari because there is no reload button nor a “swipe down to refresh” action. It’s very frustrating for users, as well as for me who asks them to restart their phones.

Has anyone been in the same situation?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Got this error after refreshing page in ReactJS app: Uncaught ...
I keep getting this error Uncaught SyntaxError: Unexpected token '<' after I refresh the page. The error comes from a top level component ......
Read more >
Uncaught SyntaxError: Unexpected token; Menu doesn't ...
Uncaught SyntaxError : Unexpected token; Menu doesn't respond to click. This code below was accepted by auto check even though the syntax error...
Read more >
Uncaught SyntaxError: Unexpected token "<" : r/reactjs - Reddit
Hi guys, it's a weird issue I've got after I deployed my PWA application to prod (EKS). Some users and one of my...
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