简体   繁体   中英

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

web: index.html

in my webpack:

entry: {
    bundle: './src/index.js'
},
output: {
    publicPath : '/',
    path: path.resolve(__dirname,'build'),
    filename: '[name].[chunkhash].js'
},

and in 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[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

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

So do I need to point to build/index.html in Procfile?? or is it some other way all the examples have seen are about create-react-app and 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM