Donovan Charpin
Donovan Charpin

Reputation: 3397

Deploy react redux starter kit on Heroku

I downloaded the starter kit for react and redux. It's really nice and works fine in localhost with the command npm run dev but I'm not able to deploy it on the server.

First, I use the command npm run deploy which clean and compile my src folder in the dist folder. Then, I deploy the server on Heroku. Once all is built, the server run npm start which execute the command babel-node bin/server. This command is not recognized by the heroku server.

I would really appreciate if someone could help me to debug this. I tried to clone again the repo, then :

  1. npm install
  2. npm run deploy
  3. Publish on Heroku and I have the same error without changing anything on the code.

Upvotes: 3

Views: 1491

Answers (1)

Ghislaindj
Ghislaindj

Reputation: 1793

The reason it doesn't work on heroku is because there isn't any production server ready in this project for your deployment as specified here : https://github.com/davezuko/react-redux-starter-kit#deployment

When you run the npm run deploy command, all the front-end code is compiled in the /dist folder.

In order to deploy it on heroku you need to :

  • Create a very simple http server always serving the file index.html. Here is the main part using Express or Koa app.get('/', function(req, res) { res.sendFile(path.join(__dirname + '/dist/index.html')); });

  • Modifying the npm start script in order to target this new production ready server.

Upvotes: 1

Related Questions