相关疑难解决方法(0)

停止调试器后如何让vscode同时停止nodemon和npm?

我正在运行以下 launch.json 配置和 package.json 脚本,它运行良好,我能够运行该应用程序并对其进行调试。但是,当我点击 vscode 调试器中的“停止”按钮时,nodemon 停止了,但 npm 进程(和整个应用程序)继续运行。如果我修改一个文件并保存它,那么 nodemon 会再次恢复(如预期的那样)。真正停止应用程序的唯一方法是在终端中按 ctrl+c。单击调试器停止按钮后,有没有办法停止两个进程?

package.json 脚本

"scripts": {
 "start": "node app",
 "debug": "nodemon --experimental-modules --inspect ./bin/www.mjs"
}
Run Code Online (Sandbox Code Playgroud)

launch.json 配置

{
 "type": "node",
 "request": "launch",
 "name": "Launch via NPM",
 "runtimeExecutable": "npm",
 "runtimeArgs": [
  "run-script",
  "debug"
 ],
 "port": 9229,
 "restart": true,
 "console": "integratedTerminal"        
}
Run Code Online (Sandbox Code Playgroud)

npm visual-studio-code

5
推荐指数
1
解决办法
446
查看次数

从 postDebugTask 中终止另一个任务 - VS Code

我有一个launch.json如下所示的调试启动配置 ( )。

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Current TS File",
            "type": "node",
            "request": "launch",
            "preLaunchTask": "Pre Debug Task",
            "postDebugTask": "Stop Watch Styles",
            "args": ["${relativeFile}"],
            "runtimeArgs": ["--nolazy", "-r", "ts-node/register"],
            "sourceMaps": true,
            "cwd": "${workspaceRoot}",
            "protocol": "inspector",
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

我的任务配置(tasks.json)就像

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "npm",
            "script": "next:copy",
            "label": "Copy Files",
            "problemMatcher": []
        },
        {
            "type": "npm",
            "script": "styles:tsw",
            "label": "Watch Styles",
            "problemMatcher": [],
        },
        {
            "label": "Pre Debug Task",
            "isBackground": true,
            "dependsOn" …
Run Code Online (Sandbox Code Playgroud)

visual-studio-code vscode-tasks vscode-debugger

3
推荐指数
2
解决办法
4012
查看次数