2016-06-12 1 views
2

Node.JS 응용 프로그램에서 Passport를 사용하여 인증에 대한 자습서를 따르려고합니다. npm-1을 사용하여 NodeJS 응용 프로그램의 문제를 해결하는 방법을 잘 모르고 있음을 깨달았습니다. debug.log 일반적으로 AngularJS 측에 있습니다. 특히 다음과 같은 문제가 있습니다. 누군가가 내게 어떤 문제가 될 수 있다고 말할 수 있습니까? 필요한 경우 관련 코드를 추가로 게시 할 수 있습니다. NPM-debug.log를npm-debug.log를 읽는 방법 (Node.JS 응용 프로그램 문제 해결)

0 info it worked if it ends with ok 
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ] 
2 info using [email protected] 
3 info using [email protected] 
4 verbose run-script [ 'prestart', 'start', 'poststart' ] 
5 info lifecycle [email protected]~prestart: [email protected] 
6 silly lifecycle [email protected]~prestart: no script for prestart, continuing 
7 info lifecycle [email protected]~start: [email protected] 
8 verbose lifecycle [email protected]~start: unsafe-perm in lifecycle true 
9 verbose lifecycle [email protected]~start: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/selfishman/www/sites/Playground/passport-local/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/mysql/bin 
10 verbose lifecycle [email protected]~start: CWD: /Users/selfishman/www/sites/Playground/passport-local 
11 silly lifecycle [email protected]~start: Args: [ '-c', 'node ./bin/www' ] 
12 silly lifecycle [email protected]~start: Returned: code: 1 signal: null 
13 info lifecycle [email protected]~start: Failed to exec start script 
14 verbose stack Error: [email protected] start: `node ./bin/www` 
14 verbose stack Exit status 1 
14 verbose stack  at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:232:16) 
14 verbose stack  at emitTwo (events.js:87:13) 
14 verbose stack  at EventEmitter.emit (events.js:172:7) 
14 verbose stack  at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:24:14) 
14 verbose stack  at emitTwo (events.js:87:13) 
14 verbose stack  at ChildProcess.emit (events.js:172:7) 
14 verbose stack  at maybeClose (internal/child_process.js:818:16) 
14 verbose stack  at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5) 
15 verbose pkgid [email protected] 
16 verbose cwd /Users/selfishman/www/sites/Playground/passport-local 
17 error Darwin 14.5.0 
18 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "start" 
19 error node v5.1.0 
20 error npm v3.5.0 
21 error code ELIFECYCLE 
22 error [email protected] start: `node ./bin/www` 
22 error Exit status 1 
23 error Failed at the [email protected] start script 'node ./bin/www'. 
23 error Make sure you have the latest version of node.js and npm installed. 
23 error If you do, this is most likely a problem with the passport-local package, 
23 error not with npm itself. 
23 error Tell the author that this fails on your system: 
23 error  node ./bin/www 
23 error You can get their info via: 
23 error  npm owner ls passport-local 
23 error There is likely additional logging output above. 
24 verbose exit [ 1, true ] 

var express = require('express'); 
var path = require('path'); 
var favicon = require('serve-favicon'); 
var logger = require('morgan'); 
var cookieParser = require('cookie-parser'); 
var bodyParser = require('body-parser'); 
var mongoose = require('mongoose'); 
var passport = require('passport'); 
var LocalStrategy = require('passport-local').Strategy; 

var routes = require('./routes/index'); 
var users = require('./routes/users'); 

var app = express(); 

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

// uncomment after placing your favicon in /public 
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico'))); 
app.use(logger('dev')); 
app.use(bodyParser.json()); 
app.use(bodyParser.urlencoded({ extended: false })); 
app.use(cookieParser()); 

app.use(require('express-session')({ 
    secret : 'keyboard cat', 
    resave : false, 
    saveUninitialized: false 
})); 
app.use(passport.initialize()); 
app.use(passport.session()); 

app.use(express.static(path.join(__dirname, 'public'))); 

app.use('/', routes); 

//passport config 
var Account = require('./models/account'); 
passport.use(new LocalStrategy(Account.authenticate())); 
passport.serializeUser(Account.serializeUser()); 
passport.desirializeUser(Account.deserializeUser()); 

//mongoose 
mongoose.connect('mongodb://localhost/passport_local_mongoose_express4'); 

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

// error handlers 

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

// production error handler 
// no stacktraces leaked to user 
app.use(function(err, req, res, next) { 
    res.status(err.status || 500); 
    res.render('error', { 
    message: err.message, 
    error: {} 
    }); 
}); 


module.exports = app; 

package.json에게

{ 
    "name": "passport-local", 
    "version": "0.0.0", 
    "private": true, 
    "scripts": { 
    "start": "node ./bin/www" 
    }, 
    "dependencies": { 
    "body-parser": "^1.13.2", 
    "chai": "~1.8.1", 
    "cookie-parser": "^1.3.5", 
    "debug": "^2.1.1", 
    "express": "^4.13.1", 
    "express-session": "^1.10.1", 
    "jade": "^1.11.0", 
    "mocha": "~1.14.0", 
    "mongodb": "^2.1.18", 
    "mongoose": "^3.8.22", 
    "morgan": "^1.6.1", 
    "passport": "^0.2.1", 
    "passport-local": "^1.0.0", 
    "passport-local-mongoose": "^1.0.0", 
    "serve-favicon": "^2.2.0", 
    "should": "~2.1.0" 
    } 
} 
+1

은 포함하려는 종속성과 동일한 프로젝트 이름입니까? – Claies

+0

예. 그게 문제가 될까요? 내가 말했듯이, 나는이 튜토리얼을 따르고있다 : http://www.bogotobogo.com/MEAN-Stack/MEAN-Stack-MongoDB-ExpressJS-AngularJS-NodeJS-Authentication-Passport-App.php – MadPhysicist

+0

나는 잘 모르겠다. 그것은 문제가 있거나 아닙니다.하지만 문제가 프로젝트 또는 종속성에있는 것이 확실하지 않기 때문에 로그 파일을 구문 분석하는 것이 좀 더 어려워집니다. – Claies

답변

4

짧은 답변을 app.js :이 문제는 NPM과는 아무 상관이 없습니다. 응용 프로그램에 예외가 발생하는 버그가 있습니다. 당신이

node ./bin/www 

로 응용 프로그램을 시작하면 당신은 NPM의 간섭없이, 콘솔에서 스택 추적과 예외를 볼 수 있습니다.

긴 대답 :의 위의 결론에 도달 할 파일을 읽어 보자

npm-debug.log --- 라인 1 :

verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ] 

이 방금 npm start라는 것을 우리에게 알려줍니다. 당신은 이미 그것을 이미 알고있었습니다.

package.json 스크립트 :

14 verbose stack Error: [email protected] start: `node ./bin/www` 
14 verbose stack Exit status 1 
14 verbose stack  at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:232:16) 
14 verbose stack  at emitTwo (events.js:87:13) 
14 verbose stack  at EventEmitter.emit (events.js:172:7) 
14 verbose stack  at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:24:14) 
14 verbose stack  at emitTwo (events.js:87:13) 
14 verbose stack  at ChildProcess.emit (events.js:172:7) 
14 verbose stack  at maybeClose (internal/child_process.js:818:16) 
14 verbose stack  at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5) 

이 당신의 스택 트레이스의 일부입니다 : 이것은 npmnode ./bin/www

npm-debug.log 라인 (14)을 호출 아무것도했지만 있음을 알려줍니다

"start": "node ./bin/www" 

. npm없이 응용 프로그램을 호출 할 때 비슷한 결과를 얻게됩니다.

여기에서 프로그램을 디버깅하기에 충분한 정보가 없습니다. 그러나이 정보가 응용 프로그램의 어딘가에 던져지고 npm과 관련이없는 정상적인 예외라는 것을 알기를 바랍니다.