D:\Programmes\Projects\NodeJs\chat\node_modules\express\lib\express.js:108
throw new Error('Most middleware (like ' + name + ') is no longer bundled with Express and must b
installed separately. Please see
https://github.com/senchalabs/connect#middleware.');
^
Error: Most middleware (like session) is no longer bundled with Express and must be installed separatel
. Please see
https://github.com/senchalabs/connect#middleware.
at Function.get (D:\Programmes\Projects\NodeJs\chat\node_modules\express\lib\express.js:108:13)
at module.exports (D:\Programmes\Projects\NodeJs\chat\node_modules\connect-mongo\src\index.js:58:42
at Object. (D:\Programmes\Projects\NodeJs\chat\app.js:17:42)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:266:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:596:3)
Выводит ошибку. как исправить?!?!?!?!?
let mongoose = require('./libs/mongoose');
let config = require('./config');
let express = require('express')
let session = require('express-session');
let app = express();
let MongoStore = require('connect-mongo')(express);
app.use(session({
secret: config.get('session:secret'),
key: config.get('session:key'),
cookie: config.get('session:cookie'),
store: new MongoStore({mongoose_connection: mongoose.connection})
}));
app.use((err, req, res, next) => {
req.session.numberOfVisits = req.session.numberOfVisits + 1 || 1;
res.send(`Visits: ${req.session.numberOfVisits}`);
});