am using passport in node.js
我在node.js中使用护照
in my app.js
在我的app.js
var passport = require('passport')
require('./config/passport').boot(passport, config)
in passport.js
在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.
我在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?
知道为什么吗?
2 个解决方案
#1
25
Have you installed passport-local module?
你有没有安装护照本地模块?
npm install passport-local
npm安装护照本地
#2
0
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).
检查你的package.json文件。如果它不存在,则需要在编写主JS文件的同一文件夹中初始化项目(server.js或index.js或者您想要的)。
$ sudo npm init
and when installing npm modules, remeber to save them in package file:
安装npm模块时,请记住将它们保存在包文件中:
$ sudo npm install passport-local --save
I solved in this way.
我这样解决了。
#1
25
Have you installed passport-local module?
你有没有安装护照本地模块?
npm install passport-local
npm安装护照本地
#2
0
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).
检查你的package.json文件。如果它不存在,则需要在编写主JS文件的同一文件夹中初始化项目(server.js或index.js或者您想要的)。
$ sudo npm init
and when installing npm modules, remeber to save them in package file:
安装npm模块时,请记住将它们保存在包文件中:
$ sudo npm install passport-local --save
I solved in this way.
我这样解决了。