[英]React project hosted in heroku fails when open
So deployed a React project to heroku using bitbucket pipelines that is working well, but now can't seem to make heroku to open the project don't have the script npm start in my package.json and what is recommend is to create a file Procfile that is a txt and inside have 所以使用运行良好的bitbucket管道向Heroku部署了一个React项目,但现在似乎无法让heroku打开项目,我的package.json中没有脚本npm start,建议创建一个文件Procfile是一个txt和里面有
web: index.html web:index.html
in my webpack: 在我的webpack中:
entry: {
bundle: './src/index.js'
},
output: {
publicPath : '/',
path: path.resolve(__dirname,'build'),
filename: '[name].[chunkhash].js'
},
and in package.json 并在package.json中
"scripts": {
"heroku-prebuild": "npm install --only=dev",
"clean": "rimraf build",
"build": "npm run clean && webpack -p",
"serve": "webpack-dev-server --progress --colors"
},
in the heroku logs getting: 在heroku日志获取:
heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=projectname.herokuapp.com request_id=a2bc33da-f938-4d7b-9395-b40442f9b2c0 fwd="88.157.88.35" dyno= connect= service= status=503 bytes= protocol=https heroku [router]:at = error code = H10 desc =“App crashed”method = GET path =“/”host = projectname.herokuapp.com request_id = a2bc33da-f938-4d7b-9395-b40442f9b2c0 fwd =“88.157.88.35” dyno = connect = service = status = 503 bytes = protocol = https
heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=projectname.herokuapp.com request_id=b2de2bdf-528e-4f97-9fe9-7f313e025ebd fwd="88.157.88.35" dyno= connect= service= status=503 bytes= protocol=https heroku [router]:at = error code = H10 desc =“App crashed”method = GET path =“/ favicon.ico”host = projectname.herokuapp.com request_id = b2de2bdf-528e-4f97-9fe9-7f313e025ebd fwd =“88.157 .88.35“dyno = connect = service = status = 503 bytes = protocol = https
Not using the create-react-app and if possible didn't want to add node express to point to the react project https://blog.bitsrc.io/react-production-deployment-part-3-heroku-316319744885 不使用create-react-app,如果可能的话,不想添加node express来指向反应项目https://blog.bitsrc.io/react-production-deployment-part-3-heroku-316319744885
So do I need to point to build/index.html in Procfile?? 所以我需要指向Procfile中的build / index.html吗? or is it some other way all the examples have seen are about create-react-app and node express.... 或者是所有示例所见的其他方式是关于create-react-app和node express ....
Was able to find the solution in the following blog where as stated the heroku runs by default npm start command if the Procfile is missing or add in the Procfile the line web: npm start
and as stated in the blog the start command in package.json runs serve -s build
where the serve is a package to point the build folder where is located the bundle and the index.html file and now it already works well. 能够在下面的博客中找到解决方案,其中默认情况下,如果缺少procfile,则运行默认npm start命令或在Procfile中添加行web: npm start
并在博客中声明package.json中的start命令运行serve -s build
,其中serve是一个包,指向build文件夹所在的bundle和index.html文件,现在它已经运行良好。 Heroku should have a default option to point to a default folder.. but all attemps that had tried failed... so thanks for @Bernard Bado and his blog for pointing to the solution. Heroku应该有一个默认选项指向一个默认文件夹..但所有尝试失败的尝试...所以感谢@Bernard Bado和他的博客指向解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.