Pra*_*ado 6 node.js visual-studio-code vscode-debugger
我正在开发一个 Node.js 应用程序,使用express.js 作为监听 PORT 3000 的 Web 框架。我使用的是 VS Code 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"
}
]
}
Run Code Online (Sandbox Code Playgroud)
我能够第一次启动调试会话,但第二次开始,我收到错误Error: Listen EADDRINUSE: 地址已在使用 :::3000
此错误是因为 VSCode 没有终止在第一个调试会话中创建的 node.exe 进程,因此在后续会话中,节点无法在端口 3000 上启动 Express 服务器,因为该服务器仍在使用中。
谁能帮我配置 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}"
}
]
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4231 次 |
| 最近记录: |