npm - 停止调试器后如何让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"
}
启动.json 配置
{
"type": "node",
"request": "launch",
"name": "Launch via NPM",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run-script",
"debug"
],
"port": 9229,
"restart": true,
"console": "integratedTerminal"
}
解决方案
似乎解决方案是添加--exitcrash
标志。它对我有用(至少当我刚开始测试它时)。所以:
"scripts": {
"start": "node app",
"debug": "nodemon --experimental-modules --inspect --exitcrash ./bin/www.mjs"
}
或者:
"runtimeArgs": [
"run-script",
"debug",
"--exitcrash"
],
我从这里得到了这个想法: https ://github.com/microsoft/vscode/issues/56756#issuecomment-462585020
推荐阅读
- google-schemas - 火车预订的收件箱操作
- r - 如何组合具有相同标识符 R 的行?
- session - 更新会话变量是否将用户踢到登录页面?
- html - 将 html 代码添加到在 R 中创建的 blogdown 网站
- mysql - 使用 powershell 变量查询 MYSQL DB
- sql-server - DBA 帮助 - 是否可以创建此自定义服务器角色?
- vba - Excel VBA 表的运行时错误“1004”
- c - Google云引擎上的内存分配(C编程)限制
- jakarta-ee - 为什么我在尝试从 WSO2 ESB 流执行此 REST API POST 请求时收到此错误?
- javascript - 下载游戏的链接/按钮