I have edited my package.json to customize the \"start\" script so it adds the --debug flag to node:
\"scripts\": {
\"start\": \"node --debug server.js
From the nodejs docs:
The legacy debugger has been deprecated as of Node 7.7.0. Please use --inspect and Inspector instead.
So starting from Node 7.7.0v use --inspect
VS Code adds a debug button inline in the package.json
file
Open package.json
and click debug above scripts
section
Select script to debug
Debugger should be attached
In your package.json define the script
"scripts": {
"debug": "node --inspect server.js"
}
And then you can use npm's run-script
npm run-script debug
or the shorter version
npm run debug