Heroku Foreman退出Express.js bodyParser()调用

fun*_*iki 2 javascript heroku node.js express foreman

当运行工头开始时,我看到以下消息

> foreman start
20:38:55 web.1  | started with pid 3896
20:38:55 web.1  | Development
20:38:56 web.1  | connect.multipart() will be removed in connect 3.0
20:38:56 web.1  | exited with code 1
20:38:56 system | sending SIGKILL to all processes
Run Code Online (Sandbox Code Playgroud)

我想知道为什么会这样,因为运行node server.js似乎没有终止服务器.

以下代码段似乎导致应用程序以退出代码1终止:

var app = express();
app.configure(function()
{
    // More config things above
    app.use(express.bodyParser());   // This line is causing the issue
    // More config things below
}
Run Code Online (Sandbox Code Playgroud)

以上是使用Express.js框架的代码.删除对express.bodyParser()的上述调用允许服务器运行(通过foreman).问题是,我需要身体解析器模块来解析我传入的get/posts请求.

对此问题的任何帮助将不胜感激.

ivo*_*szz 5

我不知道为什么领班退出时,在快递报道弃用警告信息,但可以消除这种行为替换app.use(express.bodyParser());

app.use(express.json());
app.use(express.urlencoded());

connect.multipart()将从bodyParser下一版本的Connect中删除,这可能是问题所在.您可以在Connect documenattion和/或StackOverflow问答中找到更多信息.

  • `bodyParser()= json()+ urlencoded()+ multipart()`.如果你没有使用文件上传,则不需要包含`multipart()`中间件.即使您使用文件上传,也可以使用`formidable`或任何其他模块来处理文件上传. (2认同)