git 将应用程序部署到 Heroku 时出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34631300/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error when deploying app to Heroku
提问by Mjuice
I am getting some kind of error when deploying my app to heroku using git hub. The problem is, I don't understand the heroku logs and the entailing errors. Here is the heroku log:
使用 git hub 将我的应用程序部署到 heroku 时出现某种错误。问题是,我不明白 heroku 日志和相关的错误。这是heroku日志:
Marcuss-MacBook-Pro:Weather-App marcushurney$ heroku logs
2016-01-05T14:37:27.798077+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2016-01-05T14:37:27.798377+00:00 app[web.1]: npm ERR! /app/npm-debug.log
2016-01-05T14:37:27.786949+00:00 app[web.1]: npm ERR! node v5.1.1
2016-01-05T14:37:27.786556+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2016-01-05T14:37:27.787856+00:00 app[web.1]: npm ERR! npm v3.3.12
2016-01-05T14:37:28.776245+00:00 heroku[web.1]: Process exited with status 1
2016-01-05T14:37:28.789412+00:00 heroku[web.1]: State changed from starting to crashed
2016-01-05T17:27:16.684869+00:00 heroku[web.1]: State changed from crashed to starting
2016-01-05T17:27:17.853743+00:00 heroku[web.1]: Starting process with command `npm start`
2016-01-05T17:27:20.423495+00:00 app[web.1]: npm ERR! node v5.1.1
2016-01-05T17:27:20.423130+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2016-01-05T17:27:20.424111+00:00 app[web.1]: npm ERR! npm v3.3.12
2016-01-05T17:27:20.425937+00:00 app[web.1]: npm ERR! missing script: start
2016-01-05T17:27:20.422441+00:00 app[web.1]: npm ERR! Linux 3.13.0-71-generic
2016-01-05T17:27:20.426242+00:00 app[web.1]: npm ERR!
2016-01-05T17:27:20.426432+00:00 app[web.1]: npm ERR! If you need help, you may report this error at:
2016-01-05T17:27:20.426634+00:00 app[web.1]: npm ERR! <https://github.com/npm/npm/issues>
回答by L. Meyer
You have to inform heroku where to start : missing script: start
. In your package.json, you should have something like this:
你必须通知 heroku 从哪里开始:missing script: start
。在你的package.json,你应该有类似这样:
"scripts": {
"start": "node index.js"
}
Where index.js
is your entry point.
index.js
你的切入点在哪里。
As an alternative, you can specify in Procfile
:
作为替代方案,您可以指定Procfile
:
web: node index.js
回答by Dawit Abraham
My silly mistake was that I was pushing the master branch to Heroku while my changes were in another branch!
我的愚蠢错误是我将 master 分支推送到 Heroku 而我的更改在另一个分支中!
Make sure that you merge your latest branch with your master branch first
确保首先将最新分支与主分支合并
> git checkout master
> git merge your-latest-branch
> git push heroku master
回答by xameeramir
回答by Rahul Sonone
I also faced similar kind of errors for my node js app while publishing it to heroku.com
我的 node js 应用程序在发布到 heroku.com 时也遇到了类似的错误
First create a procfile, procfile is a simple text file but without any extension.
首先创建一个procfile,procfile是一个简单的文本文件但是没有任何扩展名。
Place only one line in procfile as of now.
现在只在 procfile 中放置一行。
web: npm start
Now create the package.json file using command
现在使用命令创建 package.json 文件
npm init
once your package.json file got created please place the start property inside scripts.
创建 package.json 文件后,请将 start 属性放在脚本中。
"scripts": {
"start": "node app.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
now commit all (procfile/package.json) pending files. and deploy app again from heroku.
现在提交所有 (procfile/package.json) 待处理文件。并从heroku再次部署应用程序。