Serialization of a User Object, stuck

Hi, folks. For some reason, I can’t seem to pass the final requirement of this challenge, “MongoDB properly required, including the ObjectId.”
My code so far:

"use strict";

const express = require("express");
const bodyParser = require("body-parser");
const fccTesting = require("./freeCodeCamp/fcctesting.js");
const session = require('express-session');
const passport = require('passport');

// This is the line that should satisfy the requirement.
// I also tried this with require('mongodb').ObjectId, 
// since it's spelled that way in the failed requirement.
const ObjectID = require('mongodb').ObjectID;

const app = express();

  secret: process.env.SESSION_SECRET,
  resave: true,
  saveUninitialized: true

passport.serializeUser((user, done) => {
  done(null, user._id);
passport.deserializeUser((id, done) => {
  // db.collection('users').findOne(
  //   {_id: newObjectID(id)}, (err, doc) => {
  //     done(null, null);
  //   })
  done(null, null);

fccTesting(app); //For FCC testing purposes
app.use("/public", express.static(process.cwd() + "/public"));
app.use(bodyParser.urlencoded({ extended: true }));
app.set("view engine", "pug");

app.route("/").get((req, res) => {
  res.render(process.cwd() + "/views/pug/index.pug", {
    title: "Hello",
    message: "Please login"

app.listen(process.env.PORT || 3000, () => {
  console.log("Listening on port " + process.env.PORT);

I’ve even gone looking for other people’s working code and copy-pasted that line. Also tried requiring just mongodb by itself separately. Still no luck. Any advice would be greatly appreciated.
The full project can be found here:!/luos-fcc-advanced-node-and-express. I do have an outdated version of mongodb as a dependency, but updating it makes every part of the challenge fail…

Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36.

Link to the challenge:

Not sure what is happening here.

const ObjectID = require('mongodb').ObjectID; is correct to me. I checked my project that is exactly what I have in my code and it also fails the test now.

add console.log(new ObjectID('test')) and check the console. If you see the same as below, I’d move on to the next challenge.

Note there are a few bugs in the Advanced Node & Express section you might run into; this one got me for a while so hopeful it helps in your near future: Advanced Node and Express - Set up the Environment SET UP

Try not passing anything to new ObjectID()

Oof. Thanks for the upcoming advice!

ObjectID is not in use at this stage of the project, and there is no new ObjectID in the code.

I’ve got exactly the same issue. Please update if you have solved it.

1 Like

FINALLY SOLVED IT. Took me over an hour. You have to move to the next challenge and require mongo and then comment out only {_id: new ObjectID(id)}.

passport.deserializeUser((id, done) => {
// {_id: new ObjectID(id)},
(err,doc) => {
done(null, null);