Node.js:简单的应用程序无法在 Heroku 上运行

标签 node.js deployment heroku

我已经编写了一个基本的 node.js 应用程序,并且已经成功地将它部署到 Heroku 上,没有任何问题。我已经创建了我的 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 是您希望为您的应用生成的进程数。

关于Node.js:简单的应用程序无法在 Heroku 上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13011881/

相关文章:

node.js - 可能的 socket.io 内存泄漏

node.js - 如何通过 webapp 将 1 TB 文件上传到 Amazon S3?

deployment - 使用Grunt和rsync将远程文件夹与本地文件夹同步

Node.js 文件上传不起作用

node.js - 在 scrape-it 中设置用户代理

c# - 为什么 Visual Studio 在选择设备时尝试部署到模拟器

javascript - 预渲染页面 "/"时发生错误。 Vercel | 部署错误Next.js

ruby-on-rails - 让 Puma Postgres Server 在开发中与 Heroku 合作,或者回到 Sqlite 有意义吗?

reactjs - 在 HEROKU 上从 http 重定向到 https

css - 文件的 Rails-Heroku-SASS 语法错误