i move my source window to ubuntu :
Error: Most middleware (like json) is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware.
this is my source thank you
var http = require('http'); var fs = require('fs'); var express = require('express'); var mysql = require('mysql'); var ejs = require('ejs'); var app = express(); app.use(express.bodyParser()); app.use(app.router);
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());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With