Node.js VS代码调试器在停止调试器后不会终止节点进程
我正在开发一个node.js应用程序,使用express.js作为web框架,监听端口3000。 我使用的是VS代码v1.46 我的launch.json文件是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/
{
// 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}"
}
]
}