在.vscode 下创建文件 tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "dev:debug",
"group": "build",
"problemMatcher": [],
"label": "npm: dev:debug",
"detail": "nest start --debug --watch"
}
]
}
在.vscode 下创建文件 launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
// 调试方式改为附加
"request": "attach",
"name": "Attach Nest",
"skipFiles": [
"<node_internals>/**"
],
// 启动调试器之前运行任务进行编译TS项目
"preLaunchTask": "npm: dev:debug",
"outFiles": [
"${workspaceFolder}/dist/**/*.js"
]
}
]
}
按住快捷键ctrl shift 输入toggle,设置为总是
然后重启vscode项目,输入nest start --debug --watch 启动
会出现如下按钮,然后接下来就是老套路了