来自Heroku Toolbelt的Foreman退出时出现错误:每次都写EINVAL

Lin*_*son 6 javascript heroku node.js foreman heroku-toolbelt

遵循Heroku的入门教程比我预期的更令人沮丧.我现在所拥有的可能是一个配置问题,它可以在不到10次点击的情况下解决,但我不知道这些点击是什么,它正在推动我的问题.

工头不会开始.我没有Ruby,Heroku或Foreman的经验,也没有任何网络编程经验,所以我完全不知道这里发生了什么.这是我得到的错误消息,运行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)
Run Code Online (Sandbox Code Playgroud)

谷歌正在躲避我.任何搜索都无法找到答案.我重新启动,重新安装,重写,重新复制,重读等等,我找不到解决方案.我的代码完全反映了上面链接的"入门"页面上的代码,为方便起见,我将在此处粘贴:

Procfile:

web: node web.js
Run Code Online (Sandbox Code Playgroud)

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);
});
Run Code Online (Sandbox Code Playgroud)

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"
  }
}
Run Code Online (Sandbox Code Playgroud)

再次,我完全按照"入门"页面上的内容进行操作,但是工头拒绝启动.这里发生了什么?

Mik*_*Dev 8

这是一个类似的Stackoverflow Q/A:
Node.js Expres.js Heroku Toolbelt> Foreman Start - 错误:编写EINVAL

我和Jek有同样的问题.我使用快递4.4.4.我降级快递3.2.6并且它有效,但我不应该被迫使用较旧版本的快递,因为工头不支持它.

我试过节点工头.它对我有用.我按照包含这些步骤的说明进行操作:

  1. npm install -g foreman
  2. 从一开始

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


Lin*_*son 0

这不是一个很好的解决方案,但我已经弄清楚如何让工头工作。入门页面上的说明必须已损坏或已过时。以下是我让领班工作的方法:

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

我不知道为什么这有效,而前面的步骤却不起作用。祝你好运,未来的搜索者,在你的探索中。