大多数中间件(如压缩)不再与 捆绑在一起.错误



请帮帮我 我该如何解决这个问题?

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

你已经将你的 express 更新到 4.0,但它现在没有包含所有的中间件,所以你必须手动安装它们。

请参阅迁移到 Express 4.0 指南

Express 4 不再依赖于 Connect,并且从其核心中删除了所有内置中间件,除了 express.static。这意味着 Express 现在是一个独立的路由和中间件 Web 框架,Express 版本控制和发布不受中间件更新的影响。

删除内置中间件后,必须显式添加运行应用所需的所有中间件。 只需按照以下步骤操作:

安装模块:npm install --save

在您的应用中,需要模块:require('模块名称');

根据其文档使用该模块:app.use( ... );

相关内容

最新更新