如何在Node React Web App上使用Heroku [英] How to use heroku on a node react web app

查看:95
本文介绍了如何在Node React Web App上使用Heroku的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图遵循官方的tuto,但是没有用.

I tried to follow the official tuto but it doesn't works.

我的项目看起来像这样: 我的应用 api package.json 应用程序 package.json

My project looks this: my-app api package.json app package.json

推荐答案

如果heroku没有检测到您的buildpack,请遵循此答案.

If heroku is not detecting your buildpack, follow this answer.

反之,即使您定义了buildpack,您的应用也没有运行,这可能是因为proc文件未正确定义.

If in other hand, your app is not running even if you defined your buildpack it might be because your proc file is not properly defined.

在您的应用程序中,必须在目录的基础上创建一个名为Procfile的文件(无扩展名).该文件将告诉heroku要运行什么.

In your app, a file called Procfile must be created (with no extension) in the base of your directory. This file will tell heroku what to run.

这个例子很简单.例如,如果您的应用程序具有server.js文件,则可以按以下方式定义procfile:

A very simple example is this one. If for example your app has a server.js file, the procfile can be defined like this:

web: node server.js

如果您的目录中有此文件,然后推送到heroku,heroku将了解它是一个节点应用程序,并将正确地为您的应用程序提供服务.

If you have this file in your directory and you push to heroku, heroku will understand that it is a node app and will serve your app correctly.

这篇关于如何在Node React Web App上使用Heroku的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆