2013-11-15 125 views
1

我已經「Google搜索」並在此處找到許多類似的答案。這是我的確切錯誤。NodeJS - 推送被拒絕,未檢測到雪松支持的應用程序

$ 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 [email protected]:vidperdiem.git 
! [remote rejected] master -> master (pre-receive hook declined) 
error: failed to push some refs to '[email protected]: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" 
    } 
} 


Procfile

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')); 
}); 
+2

快速猜測:確保'Procfile'和'package .json'確實被git跟蹤 –

+0

@NitzanShaked我使用了Github的默認'.gitignore',所以這不是問題。問題是我在Github上創建了回購,然後在本地克隆,然後在該文件中,我創建了nodejs應用程序。所以我能夠推動改爲github作爲我的起源,但與heroku我不在根。所以我將這些文件複製出應用程序文件夾並將它們帶入主文件夾。我應該用學到的教訓刪除我的問題或答案嗎? – JGallardo

+1

答案與經驗教訓。你甚至可以接受你自己的答案。這是在常見問題。路要走。 –

回答

6

如果您正在運行到這一挑戰和許多人一樣沒有,請確保您有基本覆蓋。在我的情況下,我需要在推向Heroku時紮根。這聽起來很明顯,讓我解釋這是怎麼發生的,以便你可以避免這種挫敗感。

我最初在Github上創建了回購,然後在本地克隆了回購。然後在終端中,我進入了項目,其中有我在github上初始化的README.md.gitignore

那時我創建了nodejs應用程序並將其命名爲「app」。

然後,我在Heroku上創建了一個應用程序(通過網站,因爲它更容易命名它,而不是獲取長應用程序名稱),當您執行heroku create時會發生此應用程序。

我回到終端,並用heroku git:remote -a appname(其中「appname」是您的回購商的名稱)添加了heroku作爲遠程設備。

這裏的問題是,如果你在Heroku上跟蹤應用程序,這會導致它在github上成爲submodule

所以這就是爲什麼我加了heroku作爲遠程github跟蹤變化的地方。

底線: 我將文件從「app」文件夾中複製出來並放回到根目錄中。

enter image description here

確保下列文件都在你的根
app.js
package.json
Procfile

5

試圖找出一個類似的問題出來了自己,當我只是碰到這個答案跌跌撞撞。

在我的例子中,我正在從非Heroku部署轉移到Heroku部署。所以Herkou實例在我設置的新的(本地)git分支上運行,因此不是主控。

答案,一旦我解決了,就很明顯。不要打電話git push heroku master,我不得不運行git push heroku mylocalbranch:master,因爲我試圖推動舊的非Herku部署,顯然不會工作:)

相關問題