Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code, Debugging Node - How can I hit this 'Unverified Breakpoint'?

I'm just starting both with node and VSCode (and to some extent, javascript) so this may be a schoolboy error.

There's just one javascript file, writefile.js :

var fs = require('fs');

process.stdin.on('data', function (text) {
    fs.writeFileSync("test.txt", text, 'utf8');
    console.log("The file was saved.");
        process.exit();
    });


console.log('what do you want to write?');

Which works fine with no debugger attached.

Now I'm trying to debug - to keep the scenario simple, I'm just manually launching node in the console with

node --debug-brk writefile.js

If I put a breakpoint on the fs.writeFileSync line, when I attach the debugger in Visual Studio Code, I get a message that it's an 'Unverified Breakpoint':

Unverified Breakpoint

The other breakpoints are hit fine. I'm expecting all depicted breakpoints be expected to be hit before the writeFileSync one, which should only be hit after the user input at the console.

I tried using the -nolazy option when launching node - but the breakpoint is still showing as unverified, and I also get a long pause while 'Evented IO for v8 javascript' ramps up in memory usage...

IO for v8 javascript' ramps up in memory usage...

What am I doing wrong?

like image 943
Нет войне Avatar asked Jan 28 '26 16:01

Нет войне


1 Answers

Problem was solved by upgrading node to 4.4.3 - I was on a v0.11 version from 2014.

Would still be interested in why this doesn't work in older versions.

like image 80
Нет войне Avatar answered Jan 30 '26 05:01

Нет войне