0

In my NodeJS code I put debugger; in a line I'd like to pause on, as specified by the NodeJS docs

...
 saveEvent(event, function(event, message) {
        console.log("Event Saved!");
        // combine
        eAll = eMen.concat(eWomen);

        debugger;
        models.Person.update({"_id": {"$in": eAll}}, {"eventsAttended": {"$push": event._id}}, function(err, updatedPeople){
            if (err) console.log(err);
            else {
                result.message          = message;
                result.event            = event;
                    callback(result);                    
                }

            })


        });   

However, when I run this (node debug app.js) the console does show something when it reaches this line,

break in C:\Users\Imray\Projects\DaProj\daproj-backend\db.js:415
 414
 415         debugger;
 416         models.Person.update({"_id": {"$in": eAll}}, {"eventsAttended": {"$push": event._id}}, function(err, updatedPeople){
 417             if (err) console.log(err);

but when I try checking the value of current variables, I get an error

debug> eAll
ReferenceError: eAll is not defined
    at repl:1:2
    at Interface.controlEval (_debugger.js:969:21)
    at Interface.<anonymous> (repl.js:239:12)
    at Interface.emit (events.js:95:17)
    at Interface._onLine (readline.js:202:10)
    at Interface._line (readline.js:531:8)
    at Interface._ttyWrite (readline.js:760:14)
    at ReadStream.onkeypress (readline.js:99:10)
    at ReadStream.emit (events.js:98:17)
    at emitKey (readline.js:1095:12)
debug>

Why isn't this working as expected?

1 Answer 1

1

I haven't used this but according to the docs, you have to execute 'repl' command before evaluating any variable.

So, when it stops at the debugger execute 'repl' command and then type 'eAll'.

You should definitely consider using node-inspector for debugging.

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

Comments

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.