Error: Most middleware (like bodyParser) is no longer bundled with Express

前端 未结 5 1398
粉色の甜心
粉色の甜心 2020-12-23 16:24

I need to create a web service and I am using Node.js in server. But when I am running in localhost I am getting an error:

Error: Most middleware (lik

5条回答
  •  忘掉有多难
    2020-12-23 16:55

    I am having a similar problem, and havent been able to resolve it yet.

    But as per my reading, from various sources you need to:

    1. Either update your package.json to include the dependencies for all the middleware like:

       "dependencies": {
                         "express": "*",
                         "body-parser": "*",
                         "method-override": "*",
                        .
                        .
                        .  
                      }  

      or you can just run each one separately on the command prompt as

      npm install body-parser --save-dev

      You will have to do this for the middleware that you use out of the short list shown here or the complete list here.

      As far as I can make out, in your code, you are using: body-parser, method-override, static and errorhandler.

    2. You will have to remove the line:

       app.use(app.router); 
      as described here

    As I said, I am also, working on it. I suggest you make the changes, and tell me if the error on the console changes.

提交回复
热议问题