Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![matt thurmond](https://uploads.teamtreehouse.com/production/profile-photos/70433/micro_matt-thurmond-better.com-headshot.jpg)
matt thurmond
8,743 Pointsconnect-mongo error: "Class constructor MongoStore cannot be invoked without 'new'"
This isn't a question, just a solution to the broken code in the "Using MongoDB as a Session Store" video.
I believe the code in the video is broken due to a new release of the connect-mongo package (v4.x).
My console error was: "Class constructor MongoStore cannot be invoked without 'new'"
To fix it, I updated the code to the following:
// require connect-mongo in app.js
const MongoStore = require('connect-mongo');
// manage user sessions in app.js
app.use(session({
secret: 'treehouse loves you',
resave: true,
saveUninitialized: false,
store: MongoStore.create({
mongoUrl: 'mongodb://localhost:27017/bookworm'
})
}));
See here for more documentation of the latest connect-mongo release: https://github.com/jdesboeufs/connect-mongo