title: "TypeError: User.serializeUser is not a function" with passport.js
body: <p>I am new to passport JS , and i was making my first program in passport, i had app.js in my main directory and user.js in the models directory inside the main directory. 
  When i tried to run the command <strong>node app.js</strong> i recieved the following error.</p>
  
  <pre><code>C:\Users\RAJ\Desktop\webD\auth\app.js:26
  passport.serializeUser(User.serializeUser()); //encrypt
                              ^
  
  TypeError: User.serializeUser is not a function
      at Object.&lt;anonymous&gt; (C:\Users\RAJ\Desktop\webD\auth\app.js:26:29)
      at Module._compile (module.js:660:30)
      at Object.Module._extensions..js (module.js:671:10)
      at Module.load (module.js:573:32)
      at tryModuleLoad (module.js:513:12)
      at Function.Module._load (module.js:505:3)
      at Function.Module.runMain (module.js:701:10)
      at startup (bootstrap_node.js:193:16)
      at bootstrap_node.js:617:3
  </code></pre>
  
  <p>Following is my two files app.js and user.js. </p>
  
  <blockquote>
    <p>app.js</p>
  </blockquote>
  
  <pre><code>var express               = require('express'),
  mongoose              = require('mongoose'),
  bodyParser            = require('body-parser'),
  passport              = require('passport'),
  User                  = require('./models/user'),
  localStrategy         = require('passport-local'),
  passportLocalMongoose = require('passport-local-mongoose');
  
  mongoose.connect("mongodb://localhost/auth_demo");
  
   var app = express();
   app.set('view engine','ejs');
  app.get("/",function(req,res){
  res.render("home");
  });
  app.use(require("express-session")({
       secret : "some random shit",
       resave: false,
      saveUninitialized: false
  }));
  //setting up passport
  app.use(passport.initialize());
  app.use(passport.session());
  
  passport.serializeUser(User.serializeUser()); //encrypt
  passport.deserializeUser(User.deserializeUser()); //decrypt
  app.get("/secret",function(req,res)
  {
    res.render("secret");
  });
   app.get("/register",function(req,res)
   {
      res.render("register");
   });
  app.listen(8000,function(){
      console.log("server has started running");
  });
  </code></pre>
  
  <blockquote>
    <p>user.js</p>
  </blockquote>
  
  <pre><code>var mongoose = require("mongoose");
  var passportLocalMongoose = require("passport-local-mongoose");
  
  var UserSchema = new mongoose.Schema({
      username: String,
      password: String
  });
  
  UserSchema.plugin(passportLocalMongoose);
  
  module.export = mongoose.model("User",UserSchema);
  </code></pre>
  
  <blockquote>
    <p>Below is the list dependencies in package.json that I installed.</p>
  </blockquote>
  
  <pre><code> "dependencies": {
      "body-parser": "^1.18.2",
      "ejs": "^2.5.7",
      "express": "^4.16.2",
      "express-session": "^1.15.6",
      "mongoose": "^5.0.8",
      "passport": "^0.4.0",
      "passport-local": "^1.0.0",
      "passport-local-mongoose": "^5.0.0"
    }
  </code></pre>