0

I have started using Node Debugger but ran into an issue with placing the debugger; within a function code block.

For example:

let listAll = () => {
    debugger;
    console.log('getting all notes')
}

When inserting debugger; inside a function code block and running node inspect notes.js - every time I use cont,c command then it skips over this debugger statement.

However, if I take it out like so:

debugger;
let listAll = () => {
    console.log('getting all notes')
} 

When running node inspect notes.js and using the cont,c command - it will stop at the debugger;

Also when trying to use the next,n command within the debugger console, it just jumps from one expression block to another and skips over the code within the code block.

I just recently updated Node to 8.6.0 but this is my first time using node inspect.

EDIT:

I am exporting the test function at the bottom of my file, but not invoking it within the same file.

module.exports = {addnote, logNote, listAll, getNote, removeNote}
11
  • 1
    listAll is a function. Do you call it somewhere? Commented Oct 2, 2017 at 21:28
  • Do you know for sure this function is being called? To hit the debugger you must be executing the line it is on Commented Oct 2, 2017 at 21:29
  • I am exporting the function to use in my (app.js) I must call the function within the same file I'm debugging to use the debugger; statement within the code block? Commented Oct 2, 2017 at 21:31
  • Yes, otherwise, its code won't be executed. So, code execution won't be broken on debugger. Commented Oct 2, 2017 at 21:32
  • So it would it make more sense to add the debugger; on the main(app.js) file where I am actually invoking the function? Commented Oct 2, 2017 at 21:33

1 Answer 1

0

As pointed out in the comments, I was running node inspector on the notes.js where the function is just being created and not invoked.

When I run node inspector list on my app.js - this invokes the function and the inspector stops at my debugger; statement!

Make sure to invoke the function you place debugger; in!

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.