Node.js:简单的应用程序不能在Heroku上工作

我已经写了一个基本的node.js应用程序,我已经设法在Heroku上部署它,没有任何问题。 我创build了我的package.jsonProcfile ,但是从日志中我发现没有正在运行的进程,因此无法获得任何响应。 可能是什么问题呢?

PS:我不想使用Express框架

我的代码:

var http = require("http"); http.createServer(function(request, response) { response.writeHead(200, {"Content-Type": "text/plain"}); response.write("Hello World"); response.end(); console.log("I am working"); }).listen(8888); 

我的package.json:

 { "name": "node-example", "version": "0.0.1", "dependencies": { }, "engines": { "node": "0.8.x", "npm": "1.1.x" } } 

日志:

 2012-10-22T12:36:58+00:00 heroku[slugc]: Slug compilation started 2012-10-22T12:37:07+00:00 heroku[slugc]: Slug compilation finished 2012-10-22T12:40:55+00:00 heroku[router]: Error H14 (No web processes running) -> GET aqueous-bastion-6914.herokuapp.com/ dyno= queue= wait= service= status=503 bytes= 2012-10-22T12:50:44+00:00 heroku[router]: Error H14 (No web processes running) -> GET aqueous-bastion-6914.herokuapp.com/ dyno= queue= wait= service= status=503 bytes= 

您是否缩放了heroku应用程序?

 $ heroku ps:scale web=1 

这是一个必要的步骤。 1是您希望为您的应用程序生成的进程数。

改变你的端口

 .listen(8888) 

 .listen(process.env.PORT || 8888) 

你的Procfile里面有什么? 它与您的应用程序名称匹配吗?

 $ ls app.js Procfile $ cat Procfile web: node app$ $