Heroku create-react-app部署Uncaught SyntaxError:意外令牌< [英] Heroku create-react-app deploy Uncaught SyntaxError: Unexpected token <

查看:66
本文介绍了Heroku create-react-app部署Uncaught SyntaxError:意外令牌<的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我使用create-react-app buildpack部署heroku应用程序时,第一次尝试访问我的域时,加载的页面都是白色的,并且开发者控制台中显示错误

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 <

在文件 main.6396d38a.js:1 中,该文件由react版本生成.但是,当我刷新页面时,该网站运行正常.是否有可能发生这种情况?我尝试使用 npm run build serve -s build 在我的 localhost 上复制错误,但是我的网站在那儿工作得很好.为什么每次响应部署到heroku之后仅显示一次?

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?

我的package.json有一个与我的网站域名相关联的首页(不是.herokuapp.com)

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

主页":"https://www.example.com/"

推荐答案

在您的 package.json 内,确保您的 homepage URL正确:

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

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


更新

进一步的调查表明这是一个缓存问题.清除Cookie,网站内容和DNS可解决此问题.


Update

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

这篇关于Heroku create-react-app部署Uncaught SyntaxError:意外令牌&lt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆