Node and Express - Implement the Serialization of a Passport User

Hi, I have checked another post similar to this one but I can’t seem to figure it out.

I have created the database and tried to connect it but it keeps returning this error:

“Could not find node 4.4.3, using 10.”

And it does not seem to fail or get to connect to the database.

I also erased everything and copied from the hint section to see if that worked, and it does not.

This is the 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');
const ObjectID    = require('mongodb').ObjectID;
const mongo       = require('mongodb').MongoClient;

const app = express();

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')

  secret: process.env.SESSION_SECRET,
  resave: true,
  saveUninitialized: true,
console.log("Got here 1");
mongo.connect(process.env.DATABASE, (err, db) => {
    if(err) {
        console.log('Database error: ' + err);
    } else {
        console.log('Successful database connection');

        passport.serializeUser((user, done) => {
          done(null, user._id);

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

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

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

in the .env, I have


on your db url… do you have the username and password you entered on mongo? should be

mongodb+srv://USERNAME:PASSWORD@cluster… (this the user/pw you setup on mongo when you created the cluster)
otherwise you can’t connect without credentials.