3

Whenever I deploy my heroku app with the create-react-app buildpack, the first time I try to access my domain, the page loaded is white and there is an error in the developer console saying

Uncaught SyntaxError: Unexpected token <

in the file main.6396d38a.js:1 which is generated by the react build. However, when I refresh the page, the website works perfectly fine. Is there a reason this could be happening? I tried to replicate the error on my localhost using npm run build, and serve -s build but my website works perfectly fine there. Why would this only show up once after every react deploy to heroku?

My package.json has a homepage associated with the domain name of my website (not .herokuapp.com)

"homepage": "https://www.example.com/"

2
  • Could this be cache issue or potentially it's loading additional chunk? Commented Sep 2, 2019 at 20:47
  • I don't think it's a cache issue because I can replicate the error across different browsers. What do you mean by an additional chunk? Commented Sep 2, 2019 at 20:47

1 Answer 1

6

Inside your package.json make sure your homepage URL is correct:

"homepage": "https://app.herokuapp.com/"

Update

Further investigation shows this was a caching issue. Clearing cookies, website content, and DNS fixed the issue.

Sign up to request clarification or add additional context in comments.

10 Comments

@JohnDoe Have you tried the type="text/babel" on script tag trick?
It's in the question - on line 1 of main.6396d38a.js
Yes I mean the line of code. Quick question. What version react-scripts are you using and is it using babel or JSTransform? Do you use JSX?
The files are minified in the build, so the line of code isn't really significant. I am using version 3.1.0 of react-scripts-ts and it is using babel.
Are you using TSX ?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.