I was previously using gulp and running gulp to start my application and listeners from the Visual Studio Code debugger but have recently needed to switch to running scripts
It is feasible with npm whithout having to alter your scripts
section in package.json
The trick here is to pass the --inspect-brk=9229
to node.
The command will look like npm run start -- --inspect-brk=9229
Here's the .vscode/launch.json
:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch via NPM",
"runtimeExecutable": "${env:NVM_BIN}/npm", //change this to your npm path
"runtimeArgs": [
"run-script",
"start",
"--",
"--inspect-brk=9229"
],
"port": 9229
},
]
}