出現"Most middleware (like bodyParser) is no longer bundled with Express"錯誤怎么解決
命令行里選定指定路徑然后輸入 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 (E:\dcspace\node\imooc\node_modules\ex
press\lib\express.js:89:13)
? ? at Object.<anonymous> (E:\dcspace\node\imooc\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
然后去他給的這個github上安裝了connect()中間件,為什么還是無法啟動,還是報這樣的錯呢
2016-08-09
bodyParser.urlencoded(options)
Returns middleware that only parses?urlencoded?bodies. This parser accepts only UTF-8 encoding of the body and supports automatic inflation of?gzip?and?deflate?encodings.
A new?body?object containing the parsed data is populated on the?request?object after the middleware (i.e.req.body). This object will contain key-value pairs, where the value can be a string or array (when?extended?isfalse), or any type (when?extended?is?true).
Options
The?urlencoded?function takes an option?options?object that may contain any of the following keys:
extended
The?extended?option allows to choose between parsing the URL-encoded data with the?querystring?library (when?false) or the?qs?library (when?true). The "extended" syntax allows for rich objects and arrays to be encoded into the URL-encoded format, allowing for a JSON-like experience with URL-encoded. For more information, pleasesee the qs library.
2015-04-28
bodyParser.urlencoded 中設置 extended 為 true 和為 false 有什么區別嗎?
2015-01-29
2015-01-08
首先翻譯這句英文,大概的意思就是新版的express中已經不包含bodyparser了,那就需要大家單獨安裝bodyparser,安裝命令是npm install body-parser,然后在app.js中加載body-parser模塊var bodyParser = require('body-parser'),把app.use(express.bodyParser())替換成app.use(bodyParser.urlencoded({ extended: false })),這樣調試就沒問題了。