2015-07-12 54 views
0

我已經看到了一些這些,但我似乎無法得到任何工作。在推送我的應用程序到heroku後,我得到一個應用程序錯誤。此應用程序是使用控制檯中的命令創建的0​​已發佈是我的日誌和./bin/www文件。感謝您的幫助有推送節點app到heroku節點./bin/www的問題嗎?

WWW文件:

#!/usr/bin/env node 

/** 
* Module dependencies. 
*/ 

var app = require('../app'); 
var debug = require('debug')('chore-tracker:server'); 
var http = require('http'); 

/** 
* Get port from environment and store in Express. 
*/ 

var port = normalizePort(process.env.PORT || '3000'); 
app.set('port', port); 

/** 
* Create HTTP server. 
*/ 

var server = http.createServer(app); 

/** 
* Listen on provided port, on all network interfaces. 
*/ 

server.listen(port); 
server.on('error', onError); 
server.on('listening', onListening); 

/** 
* Normalize a port into a number, string, or false. 
*/ 

function normalizePort(val) { 
    var port = parseInt(val, 10); 

    if (isNaN(port)) { 
    // named pipe 
    return val; 
    } 

    if (port >= 0) { 
    // port number 
    return port; 
    } 

    return false; 
} 

/** 
* Event listener for HTTP server "error" event. 
*/ 

function onError(error) { 
    if (error.syscall !== 'listen') { 
    throw error; 
    } 

    var bind = typeof port === 'string' 
    ? 'Pipe ' + port 
    : 'Port ' + port 

    // handle specific listen errors with friendly messages 
    switch (error.code) { 
    case 'EACCES': 
     console.error(bind + ' requires elevated privileges'); 
     process.exit(1); 
     break; 
    case 'EADDRINUSE': 
     console.error(bind + ' is already in use'); 
     process.exit(1); 
     break; 
    default: 
     throw error; 
    } 
} 

/** 
* Event listener for HTTP server "listening" event. 
*/ 

function onListening() { 
    var addr = server.address(); 
    var bind = typeof addr === 'string' 
    ? 'pipe ' + addr 
    : 'port ' + addr.port; 
    debug('Listening on ' + bind); 
} 

日誌:

2015-07-11T22:05:38.685748+00:00 app[web.1]: > node ./bin/www 
2015-07-11T22:05:38.685749+00:00 app[web.1]: 
2015-07-11T22:05:39.520258+00:00 app[web.1]: Port 48390 is already in use 

2015-07-11T22:05:39.517119+00:00 app[web.1]: Server Running on port:48390 
2015-07-11T22:05:39.576888+00:00 app[web.1]: npm ERR! code ELIFECYCLE 

2015-07-11T22:05:39.577550+00:00 app[web.1]: npm ERR! Failed at the chore-  [email protected] start script 'node ./bin/www'. 

2015-07-11T22:05:39.578012+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system: 
2015-07-11T22:05:39.578136+00:00 app[web.1]: npm ERR!  node ./bin/www 

回答

1

這個問題我已經在別處見到過,但我發現,工作並沒有任何答案。如果我也發佈了我的app.js文件,它可能會有所幫助。 Heroku不喜歡的是我有'app.listen(port);'在我的app.js文件和我的./bin/www文件中。我在我的app.js文件中註釋掉了一個,所以只有www文件正在監聽,然後將改變提交給git,並推回到heroku master。然後$ heroku open和它的工作