简体   繁体   English

将Express React Redux模板部署到Heroku的步骤

[英]Steps to Deploy Express React Redux template to Heroku

Limited experience with Node and deploying to Heroku. 在Node和部署到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. 我已经使用此样板创建了一些东西: https : //github.com/DimitriMikadze/express-react-redux-starter,但实际上不确定如何设置模板以部署到Heroku。

Any basic steps would be super helpful. 任何基本步骤都将非常有帮助。 Thank you! 谢谢!

Heroku's docs are actually really great! Heroku的文档实际上真的很棒! https://devcenter.heroku.com/articles/getting-started-with-nodejs . 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. 我将逐步浏览该教程以首先部署Heroku的示例存储库,以确保您正确安装了他们的工具包并大致了解其工作原理,这不会花费很长时间。 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 . 我知道您必须进行的一项更改是您放入Procfile中的内容 Yours will need to look something like this: web: npm run build && npm start hope that helps! 您的外观将如下所示: web: npm run build && npm start希望对您有所帮助!

The Heroku + NodeJS getting started tutorial was incredibly helpful. Heroku + NodeJS入门教程非常有用。 After fiddling around with deploying to Heroku I realized my problems were as following: 摆弄到Heroku后,我意识到我的问题如下:

  1. pm2 dependency -- as suggested I removed it and replace the npm start script to just PORT=8080 node start ./server.js pm2依赖关系-根据建议,我将其删除,并将npm start脚本替换为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 A.“开始”未定义,B。我收到了一个Heroku错误“ web-process-failed-to-bind-to-port”,C。缺少Webpack和其他依赖项

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! 通过简单地删除硬编码的端口并“启动”-因此脚本现在仅是node ./server.js ,并且修复了所有devDependencies并将我的Heroku配置设置为NPM_CONFIG_PRODUCTION: false现在可以正常工作! Huzzah. 好哇。 Thanks for the assistance on this. 感谢您的协助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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