Advanced Node and Express error

So yea, I got stuck. I even decided to simply copy server.js file provided by you guys on GitHub Gist, but I get

const MongoStore = require(‘connect-mongo’)(session);
^
TypeError: Class constructor MongoStore cannot be invoked without ‘new’

I’ll try to solve this myself of course, but you should look into it.
All dependencies were installed directly from Repl.it, so maybe there’re some issue with newer versions of some of them…

Challenge: Authentication with Socket.IO

Link to the challenge:

1 Like

Welcome, there.

We are aware of this issue: Advanced Node and Express - Package Versioning · Issue #39521 · freeCodeCamp/freeCodeCamp (github.com)

The solution is as you suggested - downgrade the package version.

2 Likes

halo. i also found same problem but i downgraded the version of connect-mongo package from v4 to v3
try unistalling connect mongo

npm uninstall connect-mongo

then install connect v3

npm i connect-mongo@3
9 Likes

This worked for me. Thanks.

I would also like to comment that this worked for me after weeks of research on the internet, thanks guys , much appreciate

Welcome, fonsusali.

We are trying to make sure there are no weird bugs in this, and thought we had resolved this issue. So, would you mind elaborating on what you experienced during this challenge?

Specifically, the challenge mentions:

connect-mongo@~3.2.0, 

Does this not work for you?

It worked for me, after I downgraded connect-mongo to npm i connect-mongo@3, it worked fine and the above error disappeared, and sessions was running fine on Mongodb

Bro thanks …

thankyou for helping bro/sis/gf

1 Like

It works for me. Tks!!!

1 Like

Thanks dear. It works for me.
I appreciate you and your team.

Worked for me, too. Thanks!!