Most middleware (like compress) is no longer bundled with .. ERROR

点点圈 提交于 2019-12-12 00:28:41

问题


Please, help me How can i solve this problem?

Starting static webserver: /home/ubuntu/node/node_modules/express/lib/express.js:89
      throw new Error('Most middleware (like ' + name + ') is no longer bundle
            ^
Error: Most middleware (like cookieParser) is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware.
    at Function.Object.defineProperty.get (/home/ubuntu/node/node_modules/express/lib/express.js:89:13)
    at Object.<anonymous> (/home/ubuntu/node/static-app.js:26:16)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:124:16)
    at node.js:811:3

回答1:


You have updated your express to 4.0, but it doesn't have all the middleware included now, so you have to install them manually.

See the Moving to Express 4.0 guide

Express 4 no longer depends on Connect, and removes all the built-in middleware from its core, except express.static. This means Express is now an independent routing and middleware web framework, and Express versioning and releases are not affected by middleware updates.

With the built-in middleware gone, you must explicitly add all the middleware required to run your app. Simply follow these steps:

Install the module: npm install --save

In your app, require the module: require('module-name');

Use the module according to its documentation: app.use( ... );



来源:https://stackoverflow.com/questions/27960186/most-middleware-like-compress-is-no-longer-bundled-with-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!