2016-08-05 10 views
0

ノードJs、パスポート検証システムを学習しようとしています。私はエラーを取得していますPassport-Mongo、プロパティ 'toLowerCase'が未定義です

http://code.tutsplus.com/tutorials/authenticating-nodejs-applications-with-passport--cms-21619

NPM開始で「未定義の 『toLowerCaseメソッド』プロパティを読み取ることができません」:私はこのチュートリアルを次しています。

コードにtoLowerCase関数が表示されないため、このエラーの内容を理解できません。ここで

は私のpackage.jsonです:

{ 
    "name": "passport-mongo", 
    "version": "0.0.1", 
    "private": true, 
    "scripts": { 
    "start": "node ./bin/www" 
    }, 
    "dependencies": { 
     "express": "~4.2.0", 
     "static-favicon": "~1.0.0", 
     "morgan": "~1.0.0", 
     "cookie-parser": "~1.0.1", 
     "body-parser": "~1.0.0", 
     "express-session": "~1.0.4", 
     "debug": "~0.7.4", 
     "jade": "~1.3.0", 
     "passport": "~0.2.0", 
     "passport-local": "~1.0.0", 
     "mongodb": "^2.1.16", 
     "mongoose": "^4.4.12", 
     "bcrypt-nodejs" : "*", 
     "connect-flash" : "*" 
    } 
    } 

ここ

var express = require('express'); 
var path = require('path'); 
var favicon = require('static-favicon'); 
var logger = require('morgan'); 
var cookieParser = require('cookie-parser'); 
var bodyParser = require('body-parser'); 

var dbConfig = require('./db.js'); 
var mongoose = require('mongoose'); 
// Connect to DB 
mongoose.connect(dbConfig.url); 

var app = express(); 

// view engine setup 
app.set('views', path.join(__dirname, 'views')); 
app.set('view engine', 'jade'); 

app.use(favicon()); 
app.use(logger('dev')); 
app.use(bodyParser.json()); 
app.use(bodyParser.urlencoded()); 
app.use(cookieParser()); 
app.use(express.static(path.join(__dirname, 'public'))); 

// 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()); 

// Using the flash middleware provided by connect-flash to store messages in session 
// and displaying in templates 
var flash = require('connect-flash'); 
app.use(flash()); 

// Initialize Passport 
var initPassport = require('./passport/init'); 
initPassport(passport); 

var routes = require('./routes/index')(passport); 
app.use('/', routes); 

/// catch 404 and forward to error handler 
app.use(function(req, res, next) { 
    var err = new Error('Not Found'); 
    err.status = 404; 
    next(err); 
}); 

// development error handler 
// will print stacktrace 
if (app.get('env') === 'development') { 
    app.use(function(err, req, res, next) { 
     res.status(err.status || 500); 
     res.render('error', { 
      message: err.message, 
      error: err 
     }); 
    }); 
} 

module.exports = app; 
+2

app.jsは、あなたが 'NPM開始' を実行する際の完全なスタックトレースを表示することができますか? – deeveeABC

答えて

0
C:\Projects!\Login3\passport-mongo>npm start 

> [email protected] start C:\Projects!\Login3\passport-mongo 
> node ./bin/www 

C:\Projects!\Login3\passport-mongo\node_modules\express\lib\router\index.js:116 
    var method = req.method.toLowerCase(); 
         ^

TypeError: Cannot read property 'toLowerCase' of undefined 
    at Function.proto.handle (C:\Projects!\Login3\passport-mongo\node_modules\express\lib\router\index.js:116:26) 
    at router (C:\Projects!\Login3\passport-mongo\node_modules\express\lib\router\index.js:24:12) 
    at Object.<anonymous> (C:\Projects!\Login3\passport-mongo\app.js:44:39) 
    at Module._compile (module.js:409:26) 
    at Object.Module._extensions..js (module.js:416:10) 
    at Module.load (module.js:343:32) 
    at Function.Module._load (module.js:300:12) 
    at Module.require (module.js:353:17) 
    at require (internal/module.js:12:17) 
    at Object.<anonymous> (C:\Projects!\Login3\passport-mongo\bin\www:7:11) 
    at Module._compile (module.js:409:26) 
    at Object.Module._extensions..js (module.js:416:10) 
    at Module.load (module.js:343:32) 
    at Function.Module._load (module.js:300:12) 
    at Function.Module.runMain (module.js:441:10) 
    at startup (node.js:139:18) 

npm ERR! Windows_NT 10.0.10586 
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start" 
npm ERR! node v4.4.4 
npm ERR! npm v2.15.1 
npm ERR! code ELIFECYCLE 
npm ERR! [email protected] start: `node ./bin/www` 
npm ERR! Exit status 1 
npm ERR! 
npm ERR! Failed at the [email protected] start script 'node ./bin/www'. 
npm ERR! This is most likely a problem with the passport-mongo package, 
npm ERR! not with npm itself. 
npm ERR! Tell the author that this fails on your system: 
npm ERR!  node ./bin/www 
npm ERR! You can get information on how to open an issue for this project with: 
npm ERR!  npm bugs passport-mongo 
npm ERR! Or if that isn't available, you can get their info via: 
npm ERR! 
npm ERR!  npm owner ls passport-mongo 
npm ERR! There is likely additional logging output above. 

npm ERR! Please include the following file with any support request: 
npm ERR!  C:\Projects!\Login3\passport-mongo\npm-debug.log 

C:\Projects!\Login3\passport-mongo> 
関連する問題