Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js VS代码调试器在停止调试器后不会终止节点进程_Node.js_Visual Studio Code_Vscode Debugger - Fatal编程技术网

Node.js VS代码调试器在停止调试器后不会终止节点进程

Node.js VS代码调试器在停止调试器后不会终止节点进程,node.js,visual-studio-code,vscode-debugger,Node.js,Visual Studio Code,Vscode Debugger,我正在开发一个node.js应用程序,使用express.js作为web框架,监听端口3000。 我使用的是VS代码v1.46 我的launch.json文件是 { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/

我正在开发一个node.js应用程序,使用express.js作为web框架,监听端口3000。 我使用的是VS代码v1.46

我的launch.json文件是

{
// 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",
        "program": "${workspaceFolder}\\WebApi\\index.js",
        "restart": true,
        "protocol": "inspector"
    }
   ]
  }
我可以第一次启动调试会话,但第二次以后,我会收到错误错误:listen EADDRINUSE:地址已在使用中:::3000

此错误是因为VSCode没有终止在第一次调试会话中创建的node.exe进程,因此在后续会话中,节点无法在端口3000上启动express server,因为它仍在使用中


有人能帮我配置VSCode以在我停止调试器后终止node.exe进程吗?

使用“预览”调试扩展可以正常工作

这是使用该模式的launch.json,只需确保对
package.json
输入了正确的命令即可

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node-terminal",
      "name": "Run Script: start",
      "request": "launch",
      "command": "npm run start",
      "cwd": "${workspaceFolder}"
    }
  ]
}