Heroku Toolbelt的Foreman每次都以Error: write EINVAL退出

Foreman, from the Heroku Toolbelt, exits with Error: write EINVAL every time

本文关键字:Error write EINVAL 退出 Toolbelt Foreman Heroku      更新时间:2023-09-26

跟随Heroku的入门教程比我想象的要令人沮丧得多。我现在有可能是一个配置问题,它可能可以在不到10次点击中解决,但我不知道这些点击是什么,它把我逼上了墙。

工头不启动。我没有Ruby、Heroku或Foreman的经验,也几乎没有web编程的经验,所以我完全不知道这里发生了什么。下面是我得到的错误信息,运行Windows 7 64位:

C:'Users'___________'hello_world_basics>foreman start
09:40:17 web.1  | started with pid 2408
09:40:18 web.1  | Listening on 5000
09:40:18 web.1  |
09:40:18 web.1  | Error: write EINVAL
09:40:18 web.1  |     at errnoException (net.js:904:11)
09:40:18 web.1  |     at Socket._write (net.js:645:26)
09:40:18 web.1  |     at doWrite (_stream_writable.js:226:10)
09:40:18 web.1  |     at writeOrBuffer (_stream_writable.js:216:5)
09:40:18 web.1  |     at Socket.Writable.write (_stream_writable.js:183:11)
09:40:18 web.1  |     at Socket.write (net.js:615:40)
09:40:18 web.1  |     at Console.log (console.js:53:16)
09:40:18 web.1  |     at Server.<anonymous> (C:'Users'___________'hello_world_basics'web.js:14:11)
09:40:18 web.1  |     at Server.g (events.js:180:16)
09:40:18 web.1  | exited with code 8
09:40:18 system | sending SIGKILL to all processes
09:40:18        |     at Server.EventEmitter.emit (events.js:92:17)

Google在回避我。我怎么找也找不到答案。我重新启动,重新安装,重写,复制,重读等,我找不到一个解决方案。我的代码完全复制了上面链接的入门页面上的代码,为了方便起见,我将其粘贴在这里:

Procfile:

web: node web.js

web.js

var express = require("express");
var logfmt = require("logfmt");
var app = express();
app.use(logfmt.requestLogger());
app.get('/', function(req, res) {
  res.send('Hello World!');
});
var port = Number(process.env.PORT || 5000);
app.listen(port, function() {
  console.log("Listening on " + port);
});

packge.json

{
  "name": "hello_world_basics",
  "version": "0.0.0",
  "description": "A simple hello world app.",
  "main": "web.js",
  "scripts": {
    "test": "echo '"Error: no test specified'" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "git@heroku.com:hello_world_basics.git"
  },
  "keywords": [
    "twitter",
    "quality",
    "bestof"
  ],
  "author": "Lincoln Bergeson",
  "license": "ISC",
  "dependencies": {
    "logfmt": "^1.1.2",
    "express": "^4.4.3"
  }
}

再一次,我按照入门页上我应该做的做了所有的事情,但是foreman拒绝开始。这是怎么回事?

下面是一个类似的Stackoverflow问答:
Node.js express .js Heroku Toolbelt>Foreman Start - Error: write EINVAL

我和Jek有同样的问题。我用的是express 4.4.4。我降级了express 3.2.6,它工作了,但我不应该仅仅因为foreman不支持它就被迫使用旧版本的express。

我试过node-foreman。这对我很有效。我按照下面的说明操作:

    npm install -g foreman
  1. nf开始

我想知道是否有人有其他建议。

这不是一个很好的解决方案,但我已经想到了如何让领班工作。入门页上的说明必须是坏的或过时的。我是这样让工头干活的:

  1. 保持包。
  2. 删除web.js
  3. 通过在命令行运行express my_app_name创建一个标准的Express应用。
  4. 创建index.js文件,导入Express的app.js并启动服务器
  5. 配置Procfile指向index.js
  6. 运行foreman start,它应该工作。

我不知道为什么这工作,而前面的步骤没有。祝未来的探索者们好运。