Reputation: 34248
Im sure this is super simple but I cant seem to get the debugger going with the Launch via NPM vscode template. I have a really simple hello world with an npm script to run the app.
If I run Launch Program
(the config that uses just node) everything works perfectly, however if I use Launch via NPM
I get
/Users/luke/.nvm/versions/node/v6.5.0/bin/npm --debug-brk=3837 run-script runit
[email protected] runit /Users/luke/source/playground/js/hello-world
node index.js
hello world
And no breakpoints are hit. (Ive also tried with and without "protocol":"legacy"
)
What am I doing wrong, all the online examples suggest that this should justworkTM.
package.json
{
"name": "hello-world",
"version": "1.0.0",
"scripts": {
"runit": "node index.js"
}
}
launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch via NPM",
"runtimeExecutable": "npm",
"protocol":"legacy",
"runtimeArgs": [
"run-script",
"runit"
]
},
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/index.js"
}
]
}
index.js
console.log('hello world');//with a breakpoint set here
Upvotes: 0
Views: 958
Reputation: 34248
Ok I worked it out...
Launch via NPM requires you to add some extra args into the actual NPM script:
{
"name": "hello-world",
"version": "1.0.0",
"scripts": {
"runit": "node --nolazy --debug-brk=5858 index.js"
}
}
Upvotes: 1