express 4.x版本中模块报错
发布于 10 年前 作者 helloMane 3590 次浏览 最后一次编辑是 8 年前 来自 问答

我运行后就会在控制台报错,说是中间件貌似没有和express绑定了需要重新单独下载,但是我现在不知道具体是什么出现错误了。 D:\WebProgram\express-blog1\blog>node bin/www

Error: Most middleware (like session) is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middl eware. at Function.Object.defineProperty.get (D:\WebProgram\express-blog1\blog\node _modules\express\lib\express.js:89:13) at module.exports (D:\WebProgram\express-blog1\blog\node_modules\session-mon goose\index.js:266:15) at Object.<anonymous> (D:\WebProgram\express-blog1\blog\app.js:7:45) 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 Module.require (module.js:364:17) at require (module.js:380:17) at Object.<anonymous> (D:\WebProgram\express-blog1\blog\bin\www:7:11)

untitled1.png

在app.js的第7行我引入了一个session-mongoose的模块。代码: var MongoStore = require(‘session-mongoose’)(express);

我也下载了session-mongoose。现在不知道该怎么解决了。 希望大家能帮帮忙。

1 回复

This module currently supports only legacy versions of connect (2.x) and express (2.x and 3.x) due to extensive changes made to those modules. This module should NOT be used with latest versions of connect and express. https://github.com/donpark/session-mongoose

回到顶部