Error: Most middleware (like json) is no longer bundled with Express and must be installed separately. Please see

There are a number of changes with express 4.x. Like the error says, all of the middleware has been removed.

Update your package.json to include the "new" packages, a basic list can be found here and a full list here

Using your code from above, you would just need the following:

// package.json
{
  "dependencies":
  {
    "express":"*",
    "body-parser":"*"
  }
}

Then update your source to reflect the new changes:

// app.js
var http = require('http'),
    fs = require('fs'),
    express = require('express'),
    bodyParser = require('body-parser'),
    mysql = require('mysql'),
    ejs = require('ejs');

var app = express();
app.use(bodyParser.urlencoded({
    extended: true
}));
app.use(bodyParser.json());

Note that app.use(app.router) has been removed as well.


if some middleware is not bundled with express then dont use express keyword while using them..

instead of this -

app.use(express.bodyParser());

write this -

app.use(bodyParser());