3

I am trying to follow some tutorials on authentication using Passport in Node.JS apps and have realized that I am unsure on how to troubleshoot NodeJS apps using npm-debug.log as I am generally on the AngularJS side. In particular, I have the following trouble. Could someone tell me what could be the issue? I can post additional relevant code, if needed.

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"
  }
}
4
  • 1
    is your project named the same as a dependency you are trying to include? Commented Jun 12, 2016 at 22:36
  • Yes. Would that be an issue? As I said, I am following this tutorial: bogotobogo.com/MEAN-Stack/… Commented Jun 12, 2016 at 23:08
  • I'm not sure if it is problematic or not, but it definitely makes parsing the log file a bit more challenging, because it's not obvious if the problem is with something in the project or the dependency. Commented Jun 12, 2016 at 23:36
  • Is there a quick way to rename the project at this point? Commented Jun 13, 2016 at 2:11

1 Answer 1

4

Short answer: This problem has nothing to do with npm. Your application has a bug that throws an exception. If you start your application as

node ./bin/www

then you will see the exception with stack trace on the console, without any interference of npm.

Longer answer: Let's read the files to come to the above conclusion:

npm-debug.log --- line 1:

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

This tells us that you just called npm start. You probably knew that already.

package.json scripts:

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

This tells you that npm did nothing but calling node ./bin/www

npm-debug.log line 14:

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)

This is part of your stack trace. You will get a similar output when you call your application without npm.

I don't have enough information to debug your program from here --- but I hope it helps you to know that this is just a normal exception thrown somewhere in your app and nothing related to npm.

Sign up to request clarification or add additional context in comments.

2 Comments

where can I find the error stack ? I am using plesk and but the stdout was not logged in file in which location I get this stack
Hi @Pash -- Your question is really a new question. If I were you, I'd ask Google: "Where is the error logs in plesk?"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.