Uncaught SyntaxError: Unexpected token <
See original GitHub issueIf 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:
npm ls react-scripts
(if you haven’t ejected): react-scripts @0.9.3node -v
: v6.9.5npm -v
: 3.10.10
Then, specify:
- Operating system: Windows Server 2008
- 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:
- Created 7 years ago
- Comments:19 (11 by maintainers)
Top GitHub Comments
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.
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!