NestJS: VSCode debugger setup
Set up the VS Code debugger for a NestJS TypeScript project with a launch.json file, then set breakpoints and start debugging with F5.
Debugging is inevitable for all developers and when you get the point that your code is not doing what you would expect, a debugger beats scattered console.log calls.
VSCode is definitely built for TypeScript and thus perfect for NestJS. Get started by ensuring you have VSCode installed and open your project in VSCode. For the purpose of this article install the Nest TypeScript starter scaffolding.
$ npm i -g @nestjs/cli
$ nest new my-app
Create a launch.json file in the .vscode folder at the root of the project:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"${workspaceFolder}/node_modules/**/*.js",
"<node_internals>/**"
],
"program": "${workspaceFolder}/src/main.ts",
"preLaunchTask": "tsc: watch - tsconfig.build.json",
"outFiles": [
"${workspaceFolder}/dist/**/*.js"
]
}
]
}
Now you can set breakpoints and Run -> Start Debugging or press F5.
Changelog
2026-10-26
- Updated the menu path to
Run -> Start Debugging. VS Code renamed the Debug menu to Run.- Added the location of
launch.json.- Replaced the truncated description and finished the opening sentence.
For feedback, ping me on Mastodon@tuck@fosstodon.org.