Reaction在Heroku上的应用 [英] React Application on Heroku
本文介绍了Reaction在Heroku上的应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
npm start
然而,在Heroku上部署后,我收到一条应用程序错误消息。
应用程序URL为:
https://earth-weather.herokuapp.com/
应用程序日志如下:
2021-05-12T08:05:27.430345+00:00 app[web.1]: [34mℹ[39m [90m「wds」[39m: webpack output is served from
2021-05-12T08:05:27.430467+00:00 app[web.1]: [34mℹ[39m [90m「wds」[39m: Content not from webpack is served from /app/public
2021-05-12T08:05:27.430577+00:00 app[web.1]: [34mℹ[39m [90m「wds」[39m: 404s will fallback to /
2021-05-12T08:05:27.430864+00:00 app[web.1]: Starting the development server...
2021-05-12T08:05:27.430866+00:00 app[web.1]:
2021-05-12T08:05:27.554932+00:00 heroku[web.1]: Process exited with status 0
2021-05-12T08:05:27.631647+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-12T08:05:28.728857+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=earth-weather.herokuapp.com request_id=f067160f-79fc-4336-8488-ded7e7eb5ddb fwd="183.90.36.67" dyno= connect= service= status=503 bytes= protocol=https
2021-05-12T08:05:30.511115+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=earth-weather.herokuapp.com request_id=059ee61d-fe00-4a69-9966-61506da73911 fwd="183.90.36.67" dyno= connect= service= status=503 bytes= protocol=https
2021-05-12T08:05:31.219414+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=earth-weather.herokuapp.com request_id=0f53eee2-39a0-4311-b8a3-62cb9ffcde3c fwd="35.185.241.102" dyno= connect= service= status=503 bytes= protocol=http
派生(公共)存储库位于GitHub。
感谢所能提供的任何帮助。-本杰明
推荐答案
根据您的应用程序日志行Starting the development server
,表示应用程序正在development mode
上运行,这是不应该发生的,因为它是生产环境。
原因,
根据https://devcenter.heroku.com/changelog-items/370
在Heroku上运行Node.js应用程序不再需要配置文件。如果在构建过程中您的应用程序的根目录中不存在Procfile,我们将检查您的Package.json文件中是否有Scripts.Start条目。如果存在此类条目,则会自动生成默认配置文件
$ cat Procfile
web: npm start
存储库中,因为您尚未指定配置文件。Heroku自动生成在开发时运行您的应用程序的配置文件。
当前,您的Reaction-app被视为常规node.js应用程序,因为使用的是node.js构建包,由于根目录中存在package.json
,因此会自动推断该构建包。
若要解决此问题,您需要在Heroku上使用创建-反应-应用程序-构建包。
参考:https://elements.heroku.com/buildpacks/nhutphuongit/create-react-app-buildpack
这篇关于Reaction在Heroku上的应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文