私は機関車を使用しており、パスポートを使用しようとしています。さまざまなガイドが、物事を実行するために必要なものについて特に明確ではないため、require関数についてまだ頭を悩ませています。以下は私のroutes.jsです:
// MVC routes can be mapped mapped to controllers using convenient
// `controller#action` shorthand. Standard middleware in the form of
// `function(req, res, next)` is also fully supported. Consult the Locomotive
// Guide on [routing](http://locomotivejs.org/guide/routing.html) for additional
// information.
//
passport = require('/usr/local/lib/node_modules/passport');
passport_local = require('/usr/local/lib/node_modules/passport-local');
module.exports = function routes() {
this.root('pages#main');
this.match('login', passport.authenticate('local', { successRedirect: '/',
failureRedirect: '/login' }))
}
そして、次のエラーメッセージが表示されます。
Express
500 Error: no strategy registered under name: local
at attempt (/usr/local/lib/node_modules/passport/lib/passport/middleware/authenticate.js:237:37)
at Passport.authenticate (/usr/local/lib/node_modules/passport/lib/passport/middleware/authenticate.js:244:7)
at callbacks (/usr/local/lib/node_modules/locomotive/node_modules/express/lib/router/index.js:161:37)
at param (/usr/local/lib/node_modules/locomotive/node_modules/express/lib/router/index.js:135:11)
at pass (/usr/local/lib/node_modules/locomotive/node_modules/express/lib/router/index.js:142:5)
at Router._dispatch (/usr/local/lib/node_modules/locomotive/node_modules/express/lib/router/index.js:170:5)
at Object.router (/usr/local/lib/node_modules/locomotive/node_modules/express/lib/router/index.js:33:10)
at next (/usr/local/lib/node_modules/locomotive/node_modules/express/node_modules/connect/lib/proto.js:190:15)
at Object.methodOverride [as handle] (/home/matt/node/hello/node_modules/express/node_modules/connect/lib/middleware/methodOverride.js:37:5)
at next (/usr/local/lib/node_modules/locomotive/node_modules/express/node_modules/connect/lib/proto.js:190:15)
助けてくれてありがとう