**Authentication with Socket.IO** - connect-mongo-

Tell us what’s happening:
Hi, I did everything step by step with the guide but it returned the following error code. I then tried to copy the model answer to my server.js and it also returned the same error code. What’s wrong?

/home/runner/boilerplate-advancednode-1/server.js:17
const MongoStore = require('connect-mongo')(session);
                                           ^

TypeError: require(...) is not a function
    at Object.<anonymous> (/home/runner/boilerplate-advancednode-1/server.js:17:44)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fcc-advanced-node-and-express@0.0.1 start: `node server.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the fcc-advanced-node-and-express@0.0.1 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2021-02-25T03_41_40_750Z-debug.log
exit status 1

Your project link(s)
https://repl.it/@kwan19961217/boilerplate-advancednode-1#server.js

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36.

Challenge: Learn How JavaScript Assertions Work

Link to the challenge:

2 Likes

I had the same problem and probably anyone doing the challenge from now on.

connect-mongo recently released a mayor update with breaking changes.

I could solve this error by downgrading it to version “3.0.2”.

2 Likes

Great thanks for this, I’ve been having the same issue, and this fixed it. For future reference, is the best way to solve this type of issue is by look on npm at the version history? So for “connect-mongo” here and roll it back in package.json?

Thank you, for bringing this up. We were expecting this to happen sometime:
Advanced Node and Express - Package Versioning · Issue #39521 · freeCodeCamp/freeCodeCamp (github.com)

God bless you and this post on the forum. This solved the same problem for me as well.