为什么编辑了表单页以后报如下错误?
D:\Mooc>node app.js
Error: Most middleware (like bodyParser) is no longer bundled with Express and m
ust be installed separately. Please see https://github.com/senchalabs/connect#mi
ddleware.
at Function.Object.defineProperty.get (D:\Mooc\node_modules\express\lib\expr
ess.js:89:13)
at Object.<anonymous> (D:\Mooc\app.js:8: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:906:3
D:\Mooc>
貌似都是由于git安装引起来的问题,好象是我安装的git已经不再支持bodyParser()方法了,可是我按照https://github.com/senchalabs/connect#middleware地址上说的
// parse urlencoded request bodies into req.body
var bodyParser = require('body-parser')
app.use(bodyParser.urlencoded())
替换了app.use(express.bodyParser())还是不行,报了如下错误
D:\Mooc>node app.js
module.js:340
throw err;
^
Error: Cannot find module 'body-parser'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (D:\Mooc\app.js:8:18)
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)
望老师执教!!!