Heroku create-react-app deploy Uncaught SyntaxError: Unexpected token <

被刻印的时光 ゝ 提交于 2021-01-24 11:15:28

问题


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/"


回答1:


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.



来源:https://stackoverflow.com/questions/57762536/heroku-create-react-app-deploy-uncaught-syntaxerror-unexpected-token

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!