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.jsvar 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.
In my case i was exporting a package that i didn't install i.e express package. after installing the package my issue went away. the middleware i was using is
app.use(express.json())
Check your package.json file whether you installed the package or not. If it is not installed then you might be getting same error.