Express v4.0.0 does not include --sessions command or cmd but prior versions do

StackOverflow https://stackoverflow.com/questions/23353989

  •  11-07-2023
  •  | 
  •  

Вопрос

Since I'm not intimately familiar with Express, can anybody tell me why v4.0.0 doesn't include --sessions as a command?

When I use version 3.4.8 this command is supported, but when I grab the newest version, I run into 2 issues:

  1. The Express.cmd isn't generated (I'm running on Win8.1 x64) - Therefore I had to run npm install express-generator
  2. No included support for the --sessions command

I might also be missing something and this was an intentional separation done by the Express team?

Это было полезно?

Решение

Connect middleware is no longer bundled with express. You have to install the session middleware yourself in express 4.x. For a decent guide on updating see this post.

%npm install express-session

then

var session = require ('express-session');

and replace

app.use(express.session());

with

app.use(session({secret: 'keyboard cat', cookie: { maxAge: 100000 }}));
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top