git - NodeJS - 推送被拒绝,未检测到 Cedar 支持的应用程序

标签 git node.js heroku

我已经“谷歌搜索”并在这里找到了许多类似的答案。这正是我的错误。

$ git push heroku master
Counting objects: 43, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (35/35), done.
Writing objects: 100% (43/43), 5.19 KiB, done.
Total 43 (delta 10), reused 0 (delta 0)


 !     Push rejected, no Cedar-supported app detected

To git@heroku.com:vidperdiem.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:vidperdiem.git'

是的,我确实遵循了 Heroku 指南(其中提到 NPM 安装)并验证了我在 Heroku 上的存储库是远程的

npm install

这些是我的文件

package.json

{
  "name": "vidperdiem",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node app.js"
  },
  "dependencies": {
    "express": "3.4.4",
    "jade": "*",
    "stylus": "*"
  },
  "engines": {
    "node": "0.8.x",
    "npm": "1.2.x"
  }
}


配置文件

web: node app.js


app.js

/**
 * Module dependencies.
 */

var express = require('express');
var routes = require('./routes');
var user = require('./routes/user');
var http = require('http');
var path = require('path');

var app = express();

// all environments
app.set('port', process.env.PORT || 3000);
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.json());
app.use(express.urlencoded());
app.use(express.methodOverride());
app.use(app.router);
app.use(require('stylus').middleware(path.join(__dirname, 'public')));
app.use(express.static(path.join(__dirname, 'public')));

// development only
if ('development' == app.get('env')) {
  app.use(express.errorHandler());
}

app.get('/', function(req, res){
  res.render('index', {
    title: 'Home'
  });
});

app.get('/about', function(req, res){
  res.render('about', {
    title: 'About'
  });
});

app.get('/contact', function(req, res){
  res.render('contact', {
    title: 'Contact'
  });
});

app.get('/privacy', function(req, res){
  res.render('privacy', {
    title: 'Privacy'
  });
});

app.get('/terms', function(req, res){
  res.render('terms', {
    title: 'Terms'
  });
});

app.get('/users', user.list);

http.createServer(app).listen(app.get('port'), function(){
  console.log('Express server listening on port ' + app.get('port'));
});

最佳答案

如果您像许多人一样遇到这个挑战,请确保您掌握了基础知识。就我而言,当推送到 Heroku 时,我需要处于根目录。这听起来很明显,让我解释一下这是如何发生的,以便您可以避免这种挫败感。

我最初在 Github 上创建了该存储库,然后将其克隆到本地。然后在终端中我输入了一个项目,其中包含我在 github 上初始化的 README.md 和 .gitignore 。

那时我创建了 Nodejs 应用程序并将其命名为“app”。

然后,我在 Heroku 上创建了一个应用程序(通过网站,因为命名它比获得长应用程序名称更容易),当您执行 heroku create 时,就会发生这种情况。

我回到终端并使用 heroku git:remote -a appname 添加 heroku 作为 Remote (其中“appname”是您的存储库的名称)。

这里的问题是,如果您也在 Heroku 上跟踪该应用程序,这将导致它成为 submodule在 github 上。

这就是为什么我将heroku添加为来自github跟踪更改的同一位置的 Remote 。

底线: 我将文件从“app”文件夹中复制出来,然后将其放回到根目录中。

enter image description here

确保以下文件位于您的根目录中
app.js
package.json
Procfile

关于git - NodeJS - 推送被拒绝,未检测到 Cedar 支持的应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19997881/

相关文章:

git - 在 IntelliJ 中同时推送到多个远程存储库

javascript - Nodejs 和 Mongoose : Await stops loop

javascript - 如何在 Node.js 中打印字符串的文字表示?

heroku - 在 Windows 7 上安装 Heroku Toolbelt

ruby-on-rails - 如何在 Heroku 上刷新 Varnish 缓存

git - 如何使用 git-lfs 跟踪具有正确行结尾规范化的文本文件?

Eclipse无法推送到Github

git - merge 时避免vi "PopUp"

javascript - 找不到 'core-js' 的类型定义文件

node.js - 如何设置 Apache CouchDB 以在 Heroku 上运行?