大多数中间件(如compress)不再与..ERROR捆绑在一起 [英] Most middleware (like compress) is no longer bundled with .. ERROR

查看:135
本文介绍了大多数中间件(如compress)不再与..ERROR捆绑在一起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

推荐答案

您已将express更新为4.0,但是它现在还没有包含所有中间件,因此您必须手动安装它们.

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.

请参见移至Express 4.0指南

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

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:

安装模块: npm install --save

在您的应用中,需要以下模块: require('module-name');

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

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

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

这篇关于大多数中间件(如compress)不再与..ERROR捆绑在一起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆