am using passport in node.js
in my app.js
var passport = require('passport')
require('./config/passport').boot(passport, config)
in passport.js
var LocalStrategy = require('passport-local').Strategy
run the app and i get this error message
module.js:340
throw err;
error:Cannot find module 'passport-local'
at Object.<anonymous> <F:\work\config\passport.js:2:21>
i install the passport in F:\work\node_modules.
even if i put the
var LocalStrategy = require('passport-local').Strategy
right under the
var passport = require('passport')
i still get the same error
any idea why?
Passport-Local Mongoose is a Mongoose plugin that simplifies building username and password login with Passport.
You can reset or change passwords using 2 simple functions in passport-local-mongoose. They are setPassword function and changePassword functions. Normally setPassword is used when the user forgot the password and changePassword is used when the user wants to change the password.
No need to authenticate. Retrieve user from account using findByUsername() method, which was placed on the model by passport-local-mongoose, then run setPassword() , then user. save() in the callback.
I had the same problem and I solved it:
Check your package.json
file.
If it does not exist, you need to init your project in the same folder where you wrote your main JS file (server.js
or index.js
or however you want).
$ sudo npm init
and when installing npm modules, remeber to save them in package file:
$ sudo npm install passport-local --save
I solved in this way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With