我試圖按照對Node.js的應用程序和使用Passport身份驗證一些教程已經意識到我是如何應用的NodeJS使用NPM-解決不確定debug.log,因爲我通常在AngularJS一側。特別是,我有以下麻煩。有人能告訴我可能是什麼問題?如有需要,我可以發佈其他相關代碼。如何閱讀NPM-的debug.log(故障排除的Node.js應用程序)
NPM-的debug.log
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 ]
app.js
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"
}
}
是您的項目命名一樣的,你正在嘗試包括依賴? – Claies
是的。這會成爲一個問題嗎?正如我所說的,我下面這個教程:http://www.bogotobogo.com/MEAN-Stack/MEAN-Stack-MongoDB-ExpressJS-AngularJS-NodeJS-Authentication-Passport-App.php – MadPhysicist
我不知道,如果這是有問題的或不是,但它肯定會使日誌文件解析更具挑戰性,因爲如果問題與項目中的某些內容或依賴關係有關,則不明顯。 – Claies