Exception code:
\workspaces\webstormproject\imooc-project\imooc>node app.jsError:Most Middleware (like Bodyparser) is no longer Bundled with Express and must is installed separately. Please see Https://github.com/senchalabs/connect#middleware. At Function.Object.defineProperty.get (L:\Workspaces\WebStormProject\imooc-project\imooc\node_modules\express\ lib\express.js:89:13) at object.<anonymous> (L:\Workspaces\WebStormProject\imooc-project\imooc\app.js : 12:17) at module._compile (module.js:456:26) at object.module._extensions.. JS (module.js:474:10) at module.load (module.js:356:32) at function.module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at Node.js:902:3
Current Express version: 3.5.3
According to the error can know Bodyparser has not been bound with express, the current express does not include Body-parser, execute the following command:npm install Body-parser
Solve:
var app = require (' Express '), var bodyparser = require (' Body-parser '); var multer = require (' Multer '); App.use (Bodyparser.json ()); For parsing application/jsonapp.use (bodyparser.urlencoded ({extended:true})); For parsing application/x-www-form-urlencodedapp.use (Multer ()); For parsing multipart/form-dataapp.post ('/', function (req, res) { console.log (req.body); Res.json (req.body);})
Nodejs using App.use (Express.bodyparser ()); Travel Anomalies----Solutions