1

Limited experience with Node and deploying to Heroku. I've built something up using this boilerplate: https://github.com/DimitriMikadze/express-react-redux-starter but am not really certain how to set up the template for deployment to Heroku.

Any basic steps would be super helpful. Thank you!

2 Answers 2

2

Heroku's docs are actually really great! https://devcenter.heroku.com/articles/getting-started-with-nodejs . That will walk you through deploying their example repo, but the starter kit you linked to above will work almost exactly the same. I would walk through that tutorial to deploy Heroku's example repo first just to make sure you have their toolkit properly installed and generally understand how it works, it won't take long at all. Then I would move on to deploying the app you've built. The one change I know you'll have to make is what you put in your Procfile. Yours will need to look something like this: web: npm run build && npm start hope that helps!

Sign up to request clarification or add additional context in comments.

8 Comments

Thanks much for this -- I ran through the Heroku getting started article and successfully deployed their sample application. However now when running through the same steps for my express-react-redux-starter kit app I am getting an application error. When I look at the Heroku logs I see that the systems fails on PORT=8080 pm2 start ./server.js which is from package.json -- any idea how to resolve this? Thank you again!
Is there anything else in the logs that might help?
Ah, in the readme for that starter kit: Note: I'm using pm2 for production server, you should install it on server via 'npm install pm2 -g'. if you don't want to use pm2, just change pm2 with node in package.json file in scripts section. So try changing start in package.json to "start": "PORT=8080 node start ./server.js",
Here's the output from the Heroku logs: gist.github.com/kimispencer/a4d22b74f42821fe283fca68fa25746d Agree it seems to be an issue with pm2. I changed to "start": "PORT=8080 node start ./server.js" within package.json but the error is still there... just did a fresh push to heroku master and see the change to package.json in my git logs... any idea why the change isn't getting picked up? Thx!
Can you post the new logs after the node change? All the errors in that gist are talking about pm2
|
0

The Heroku + NodeJS getting started tutorial was incredibly helpful. After fiddling around with deploying to Heroku I realized my problems were as following:

  1. pm2 dependency -- as suggested I removed it and replace the npm start script to just PORT=8080 node start ./server.js

However, that caused separate problems:

A. 'start' was undefined, B. I got a Heroku error "web-process-failed-to-bind-to-port", and C. missing Webpack + other dependencies

By simply removing the hardcoded port and "start" -- so the script is now just node ./server.js as well as fixing any devDependencies AND setting my Heroku config to NPM_CONFIG_PRODUCTION: false it works now! Huzzah. Thanks for the assistance on this.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.