Simon Guldstrand
Simon Guldstrand

Reputation: 488

Cannot call method 'use' of undefined

I have a problem with implementing passport in node.js express.

I am trying to follow different guides, but just won't succeed..

This time theres an error like this:

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 it wont work? I have installed express-session, passport, passport-local etc.

Upvotes: 3

Views: 1878

Answers (1)

Naeem Shaikh
Naeem Shaikh

Reputation: 15715

you need to initialize app with express()

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

Upvotes: 6

Related Questions