Can't call method 'use' of undefined

I have a problem embedding passport in node.js express.

I try to follow various tutorials but it just won't work.

This time an error occurs:

enter image description here

My code looks like this:

In app.js:

var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');

// Configuring Passport
var passport = require('passport');
var expressSession = require('express-session');
// TODO - Why Do we need this key ?
app.use(expressSession({secret: 'mySecretKey'}));
app.use(passport.initialize());
app.use(passport.session());

      

Any idea why this isn't working? I have set up express session, passport, passport-local, etc.

+3


source to share


1 answer


you need to initialize app

withexpress()



  var express= require('express');
    var app=express();

      

+6


source







All Articles