git Heroku 新手:将我的应用程序推送到 Heroku 时出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8165028/
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
Newbie in Heroku: Error when push my app to Heroku
提问by Mellon
I am using Ubuntu 10.04. By following the tutorial here, I have created Heroku account, installed GITand Herokusuccessfully. I have uploaded the SSH key and add heroku to my system PATH.
我正在使用 Ubuntu 10.04。按照这里的教程,我已经创建了 Heroku 帐户,成功安装了GIT和Heroku。我已经上传了 SSH 密钥并将 heroku 添加到我的系统路径中。
After that, I did the following thing:
之后,我做了以下事情:
---------- FIRST (successful)-------------
---------- FIRST(成功)-------------
$ cd PATH/TO/MY_APP
$ git init
Initialized empty Git repository in .git/
$ touch HELLO
$ git add .
$ git commit -m "Add a HELLO file"
------------THEN (successful)----------
------------THEN(成功)----------
$ heroku create
Enter your Heroku credentials.
Email: [email protected]
Password:
Uploading ssh public key /Users/joe/.ssh/id_rsa.pub
Created http://high-sunrise-58.heroku.com/ | [email protected]:high-sunrise-58.git
Git remote heroku added
----------- LAST (Which failed!!!)----------
----------- LAST(失败了!!!)---------
$ git push heroku master
Warning: Permanently added the RSA host key for IP address 'xx.xx.xx.xx' to the list of known hosts.
Counting objects: 3, done.
Writing objects: 100% (3/3), 226 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
f
-----> Heroku receiving push
! Heroku push rejected due to an unrecognized error.
! We've been notified, see http://support.heroku.com if the problem persists.
To [email protected]:high-sunrise-58.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected]:high-sunrise-58.git'
As you see above, my LAST step failed.
正如你在上面看到的,我的最后一步失败了。
What could be the possible reason for the error in my LAST step(when push my app to Heroku)?Why it is failed?
我的最后一步(将我的应用程序推送到 Heroku 时)中出现错误的可能原因是什么?为什么失败?
回答by manojlds
You cannot push any random repo to Heroku. It has to be a rails app ( or any of the other supported apps like Django, but in this case OP is working on Rails) and that is what the pre-receive hook is rejecting in your case since your repo just has some dummy file. ( NOTE that the first step in the tutorial is not creating an empty git repo, but creating one for your Rails app. See the output in the successful push example in the quickstart - Rails app detected
- means it looks for the rails app when you push something.)
您不能将任何随机存储库推送到 Heroku。它必须是一个 rails 应用程序(或任何其他受支持的应用程序,如 Django,但在这种情况下,OP 正在使用 Rails),这就是 pre-receive 钩子在你的情况下拒绝的,因为你的 repo 只有一些虚拟文件. (请注意,本教程的第一步不是创建一个空的 git 存储库,而是为您的 Rails 应用程序创建一个。请参阅快速入门中成功推送示例中的输出 - Rails app detected
- 表示它会在您推送某些内容时查找 Rails 应用程序。 )
回答by elmeltone
I got this same error after I was pushing changes to a separate heroku project in a separate terminal window. The error stopped up after I logged back in to github via the terminal for the project that was giving me the error.
在单独的终端窗口中将更改推送到单独的 heroku 项目后,我遇到了同样的错误。在我通过给我错误的项目的终端重新登录到 github 后,错误停止了。
回答by John Pang
I got this error this morning as well and turn out to be service down in Heroku (the app runs fine, but dashboard, deploy are down).
今天早上我也遇到了这个错误,结果是 Heroku 中的服务停止了(应用程序运行良好,但仪表板、部署已关闭)。
Check http://status.heroku.comfirst.
I waited a few hours and once their service back to normal, my commit success.
我等了几个小时,一旦他们的服务恢复正常,我的提交就成功了。
回答by B4BIPIN
I have also faced this problem while creating a web resume with ReactJS, when I searched for log file
当我搜索日志文件时,我在使用 ReactJS 创建网络简历时也遇到了这个问题
(which presents at --> dashboard.heroku.com/apps/{your App name}/activity)
(显示在 --> dashboard.heroku.com/apps/ {your App name}/activity)
, I saw this and Follow steps which are given below. And the issue is resolved.
,我看到了这个,并按照下面给出的步骤。并且问题解决了。
-----> Node.js app detected
-----> 检测到 Node.js 应用
-----> Build failed
-----> 构建失败
! Two different lockfiles found: package-lock.json and yarn.lock Both npm and yarn have created lockfiles for this application, but only one can be used to install dependencies. Installing dependencies using the wrong package manager can result in missing packages or subtle bugs in production.
!找到两个不同的锁文件:package-lock.json 和yarn.lock npm 和yarn 都为这个应用程序创建了锁文件,但只有一个可以用来安装依赖项。使用错误的包管理器安装依赖项可能会导致丢失包或生产中的细微错误。
- To use npm to install your application's dependencies please delete the yarn.lock file.
$ git rm yarn.lock
- To use yarn to install your application's dependences please delete
the package-lock.json file.
$ git rm package-lock.json
回答by matan yemini
If you are using node.js specify in the package.json:
如果您使用的是 node.js,请在 package.json 中指定:
"engines": {
"node": "version", (you can check the version by typing "node -v" in your cmd prompt)
},
under the name and the version definition.
在名称和版本定义下。
if you are using yarn / npm define also under the engines : "yarn": "version" / "npm" : "version".
如果您使用 yarn / npm 也在引擎下定义:"yarn": "version" / "npm" : "version"。
in addition add this command on the cmd prompt in your git folder->
此外,在 git 文件夹中的 cmd 提示符下添加此命令->
heroku config:set NPM_CONFIG_PRODUCTION=true YARN_PRODUCTION=true
回答by Ankur Devani
I was able to solve this error by performing below steps.
通过执行以下步骤,我能够解决此错误。
- git init
- git add .
- git commit -m "My first commit"
- heroku create
- git push heroku master
- git初始化
- git 添加。
- git commit -m "我的第一次提交"
- heroku 创建
- git push heroku master