为什么我不能使用5858端口,即使我没有重复端口或更改端口号?

时间:2017-09-07 07:36:21

标签: node.js visual-studio-code

启动时Node.js的典型问题。错误是:

> demo@1.0.0 dev d:\Proj\WxApp\dev\demo
> egg-bin dev "--debug"
Debugger listening on [::]:5858
2017-09-07 15:31:37,739 INFO 7800 [master] egg version 1.7.0
Error: listen EADDRINUSE :::5858
    at Object.exports._errnoException (util.js:1018:11)
    at exports._exceptionWithHostPort (util.js:1041:20)
    at Agent.Server._listen2 (net.js:1258:14)
    at listen (net.js:1294:10)
    at net.js:1404:9
    at _combinedTickCallback (internal/process/next_tick.js:83:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)

起初我认为这是重复呼叫端口的问题。所以我使用了类似" netstat -aon | findstr' 5858'"在启动VS Code之前做调试。但是我没有看到任何东西。当我启动VS Code进行调试时就会出现问题 - 即使我更改了" 5858",问题仍然出现!

这是我的launch.config:

{
    // Use IntelliSense to learn about possible Node.js debug 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 Egg",
            "cwd": "${workspaceRoot}",
            "runtimeExecutable": "npm",
            "windows": {
                "runtimeExecutable": "npm.cmd"
            },
            "runtimeArgs": [
                "run",
                "dev",
                "--",
                "--debug"
            ],
            "protocol": "legacy",
            "port": 5858
        },
        {
            "type": "node",
            "request": "attach",
            "name": "Attach Agent",
            "port": 5856
        },
        {
            "type": "node",
            "request": "attach",
            "name": "Attach Worker",
            "restart": true,
            "port": 10086
        },
        {
            "type": "node",
            "request": "launch",
            "name": "Start Program",
            "program": "${workspaceRoot}\\index.js"
        }
    ],
    "compounds": [{
        "name": "Debug",
        "configurations": ["Launch Egg", "Attach Agent", "Attach Worker"]
    }]
}

这是VSC开始调试时的图像....:

enter image description here

1 个答案:

答案 0 :(得分:0)

这是一个知道node.js的问题。这应该有所帮助。

https://github.com/node-inspector/node-inspector/issues/199