debugger; doesn't work within function code block

188 Views Asked by At

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}
1

There are 1 best solutions below

0
On

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!