javascript - Error while using node passport authentication -
i using passport authentication in application. when try initialize passport getting error. using express building application. have corr
here app.js file app.js
/** * module dependencies. */ var express = require('express') , routes = require('./routes') , user = require('./routes/user') , http = require('http') , path = require('path'); var login = require('./routes/login'); var bodyparser = require('body-parser'); var app = express(); var db = require('./db.js'); var urlencodedparser = bodyparser.urlencoded({ extended: false }); var fetch = require('./routes/collect'); var passport = require('passport'); // environments app.set('port', process.env.port || 3000); app.set('views', __dirname + '/views'); app.set('view engine', 'jade'); app.use(express.favicon()); app.use(express.logger('dev')); app.use(passport.initialize()); app.use(passport.session()); app.use(express.bodyparser()); app.use(express.methodoverride()); app.use(app.router); app.use(express.static(path.join(__dirname, 'public'))); // development if ('development' == app.get('env')) { app.use(express.errorhandler()); } app.get('/', routes.index); app.get('/users', user.list); app.get('/login',login.user); app.get('/collect',fetch.collect); app.post('/auth', urlencodedparser, auth.authentication); http.createserver(app).listen(app.get('port'), function(){ console.log('express server listening on port ' + app.get('port')); });
i getting error
app.use(passport.initialize()); ^ typeerror: object #<object> has no method 'initialize' @ object.<anonymous> (/home/kurakar/workspace/mywork/app.js:26:18) @ module._compile (module.js:456:26) @ object.module._extensions..js (module.js:474:10) @ module.load (module.js:356:32) @ function.module._load (module.js:312:12) @ function.module.runmain (module.js:497:10) @ startup (node.js:119:16) @ node.js:902:3
i have correctly defined passport module in ./routes/auth.js
file.
ps: when install passport , passport-local using npm install --save passport
, npm install --save passport-local
shows these line:
passport@0.2.1 node_modules/passport ├── passport-strategy@1.0.0 └── pause@0.0.1 passport-local@1.0.0 node_modules/passport-local └── passport-strategy@1.0.0
Comments
Post a Comment