Run & Debug: Launch.json
VS Code Run and Debugger with launch.json
NestJS
Prepare Environment
As NestJS environment, prebuild & postbuild commands are environment specific it is a good idea to run the relevant npm start command for that environment before using the VS Code debugger:
$ npm run start:dev
...
[ Press CTRL-C to exit node process so VS Code debugger may be started ]
Start the Debugger
VS Code --> Run and Debug --> Launch NestJSyr nnnnpm run setenv:dev:julian && npm run prebuildnpm run setenv:dev:julian && npm run prebuildnnnpm run setenv:dev:julian && npm run prebuild
"version": "0.2.0",
"configurations": [
{
"name": "Launch NestJS",
"type": "node",
"request": "launch",
"preLaunchTask": "npm: build",
"args": [
"${workspaceFolder}/dist/main.js"
],
"runtimeArgs": [
"--nolazy",
"-r",
"ts-node/register",
"-r",
"tsconfig-paths/register"
],
"sourceMaps": true,
"envFile": "${workspaceFolder}/.env",
"cwd": "${workspaceRoot}",
"console": "integratedTerminal",
"protocol": "inspector"
},
{
"name": "Attach NestJS by PID",
"type": "node",
"request": "attach",
"processId": "${command:PickProcess}" ],
"compounds": []
}
$ npm run setenv:dev
$ npm run prebuild
[ Execute VS Code Run and Debug after build in launch.json has completed ]
$ npm run postbuild
Angular
In the Angular launch.json we do not include environment, build & serve commands as they are envirnoment specific. Before executing:
Prepare Environment, Build & Serve:
$ npm run start:dev
Start the Debugger
VS Code --> Run and Debug --> Launch Chrome Attach Angular
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Chrome Attach Angular",
"type": "chrome",
"request": "launch",
// "preLaunchTask": "npm: start",
// "preLaunchTask": "ng serve",
"url": "http://localhost:4200/",
"webRoot": "${workspaceFolder}"
},
]
}
Last updated
Was this helpful?