简体   繁体   中英

Installing express 4.x with its middlewares?

How can i install Express and bring its middlewares, that were in the legacy version?

Sort of npm install -g , but which brings the middleware back, and why Express team dont do that?

Express 4 has unbundled itself from many of the middleware that was previously built-in. Those pieces of middleware are now available as separate modules which you can npm install into your project and then require() into your app as needed.

We could guess as to why they unbundled things (make Express more focused, more streamlined, more open to alternate middleware and more modular - generally considered desirable attributes), but only someone from the Express team could answer exactly as to why they changed it.

For example, I'm including the body-parser and cookie-parser modules into my Express 4 project so I can use their functionality as middleware. Each module you might be interested in, explains how to load it and insert it into the middleware stack.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM