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

If you are reporting a bug, please fill in below. Otherwise feel free to remove this template entirely.

### Can you reproduce the problem with latest npm? Yes.

Can you still reproduce it? Yes.

### Description What are you reporting?

I am trying to render a create-react-app build folder using express. If I run it via localhost, it works fine, no problem. However, when I try to render it via my web server (Windows Server 2008, IIS, with iisNode), I get an error saying “Uncaught SyntaxError: Unexpected token <”. This comes from the main.8b788f8.js file within the build/static/js folder.

Expected behavior

Tell us what you think should happen.

The express script should render the index.html page from the build folder with no issues.

Actual behavior

Tell us what actually happens.

Nothing is displayed at the web URL. There is one error within the console, stating the following:

main.8b78c8f8.js:1 Uncaught SyntaxError: Unexpected token <

Environment

Run these commands in the project folder and fill in their results:

  1. npm ls react-scripts (if you haven’t ejected): react-scripts @0.9.3
  2. node -v: v6.9.5
  3. npm -v: 3.10.10

Then, specify:

  1. Operating system: Windows Server 2008
  2. Browser and version: Google Chrome, Version 57.0.2987.98 (64-bit)

Reproducible Demo

Please take the time to create a new app that reproduces the issue.

Alternatively, you could copy your app that experiences the problem and start removing things until you’re left with the minimal reproducible demo.

(Accidentally, you might get to the root of your problem during that process.)

https://github.com/andehwong/counselling

By doing this, you’re helping the Create React App contributors a big time! Demonstrable issues gets fixed faster.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:19 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
gaearoncommented, Jan 10, 2018

Try opting out of caching and redeploying your app. The fix might take up to 24 hours to propagate (due to a Chrome bug) but if you don’t see it on other computers then this should be enough.

1reaction
mdo5004commented, Jan 10, 2018

I’m having a similar issue when I deploy my app to Google’s Firebase Hosting. The first time I access the page I get a blank white page and this same error in the console. However, if I refresh, everything works fine. After building my project, however, it says “The project was built assuming it is hosted at the root.”

This might be a question for Firebase hosting, but I figured I’d put it up here. I don’t see any other questions as closely related to my issue!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught SyntaxError: Unexpected token : - Stack Overflow
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 >
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 >
SyntaxError: Unexpected token in JavaScript | bobbyhadz
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 >

github_iconTop Related Medium Post

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