简体   繁体   English

打开时,heroku中托管的React项目失败

[英]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.

相关问题 成功在 react-create-app 中编译项目,但是在尝试部署到 heroku 时 - 它失败 - Succedd to compile project in react-create-app, but when trying to deploy to heroku - it fails Flask + React 应用程序在部署到 Heroku 时失败 - Flask + React App Fails When Deployed to Heroku 在 Heroku 部署后,React 客户端在指定 localhost 时失败并显示 Axios - After Heroku deployment React client fails with Axios when specifying localhost 通过 Passport.js 与 React 上的 3rd-party (discord) 进行身份验证在本地工作,但在托管在 Heroku 上时不能 - Authentication through Passport.js with 3rd-party (discord) on React works locally but not when hosted on Heroku 当托管在 heroku 上时,带有 Express 后端的 React 应用程序为 API 调用返回 404 - React app with Express backend returns 404 for API calls when hosted on heroku 当后端托管在 Azure 上时,create-react-app 代理请求失败并显示 404 - create-react-app proxy request fails with 404 when backend is hosted on Azure 部署在 heroku 上的 React 项目是空白的 - react project deployed on heroku is blank 无法将响应项目部署到heroku - Trouble deploying react project to heroku 将React项目推向Heroku的问题 - Issues pushing react project to Heroku 使用 react-navigation 时,Expo 项目无法编译? - Expo project fails to compile when using react-navigation?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM