运行VS代码调试器似乎托管了我的Web应用程序



当我不使用 npm start的情况下运行VS代码调试器时,它似乎托管了我的应用程序,因为我可以在Chrome中浏览它,而无需运行npm start。我的应用程序位于端口3000,在端口5858上的调试器。今天早些时候还没有此问题。运行Angular Universal应用程序时,我会遇到此错误,然后运行调试器进行调试node.js后端,因为两个进程试图使用同一端口。这意味着我无法通过使用GUI触发后端功能,因此很难测试后端。为什么调试我的应用似乎托管了?

这是我的启动.json文件:

{
    "version": "0.2.0",
    "configurations": [{
        "name": "Launch",
        "type": "node2",
        "request": "launch",
        "program": "${workspaceRoot}/src/server.ts",
        "stopOnEntry": false,
        "skipFiles": [
            "node_modules/**/*.js"
        ],
        "args": [],
        "cwd": "${workspaceRoot}",
        "preLaunchTask": null,
        "runtimeExecutable": null,
        "runtimeArgs": [
            "--nolazy"
        ],
        "env": {
            "NODE_ENV": "development"
        },
        "externalConsole": false,
        "sourceMaps": true,
        "outFiles": ["${workspaceRoot}/dist/**/*.js"],
        "address": "localhost",
        "port": 5858
    }, {
        "name": "Attach",
        "type": "node2",
        "request": "attach",
        "port": 5858,
        "address": "localhost",
        "restart": false,
        "sourceMaps": false,
        "outDir": null,
        "localRoot": "${workspaceRoot}",
        "remoteRoot": null
    }, {
        "name": "Attach to Process",
        "type": "node2",
        "request": "attach",
        "processId": "${command.PickProcess}",
        "port": 5858,
        "sourceMaps": false,
        "outDir": null
    }]
}

当我不使用npm start托管我的应用时,这是调试控制台:

node --inspect=5858 --debug-brk --nolazy dist/server/index.js 
Debugger listening on port 5858.
Warning: This is an experimental feature and could change at any time.
Debugger attached.
slimy sam
slimy sam
Listening on: http://localhost:3000

这是我已经使用npm start托管我的应用程序的调试控制台:

node --inspect=5858 --debug-brk --nolazy dist/server/index.js 
Debugger listening on port 5858.
Warning: This is an experimental feature and could change at any time.
Debugger attached.
slimy sam
events.js:160
      throw er; // Unhandled 'error' event
      ^
Error: listen EADDRINUSE :::3000
    at Object.exports._errnoException (util.js:1026:11)
    at exports._exceptionWithHostPort (util.js:1049:20)
    at Server._listen2 (net.js:1257:14)
    at listen (net.js:1293:10)
    at Server.listen (net.js:1389:5)
    at EventEmitter.listen (/private/var/root/vepo/node_modules/express/lib/application.js:617:24)
    at Object.<anonymous> (/private/var/root/vepo/dist/server/index.js:57532:18)
    at Object.<anonymous> (/private/var/root/vepo/dist/server/index.js:57537:30)
    at __webpack_require__ (/private/var/root/vepo/dist/server/index.js:27:30)
    at /private/var/root/vepo/dist/server/index.js:93:18
Waiting for the debugger to disconnect...

编辑:当我将其设置为false时,它也可以在启动中设置为false时停止调试器。我可能需要重新安装它,尽管我试图避免它,因为我有很多扩展。

当我更改端口时,我的应用程序运行到4000时,我在调试时会遇到相同的错误,但是4000:

events.js:160
      throw er; // Unhandled 'error' event
      ^
Error: listen EADDRINUSE :::4000
    at Object.exports._errnoException (util.js:1026:11)
    at exports._exceptionWithHostPort (util.js:1049:20)
    at Server._listen2 (net.js:1257:14)
    at listen (net.js:1293:10)
    at Server.listen (net.js:1389:5)
    at EventEmitter.listen (/private/var/root/vepo/node_modules/express/lib/application.js:617:24)
    at Object.<anonymous> (/private/var/root/vepo/dist/server/index.js:57532:18)
    at Object.<anonymous> (/private/var/root/vepo/dist/server/index.js:57537:30)
    at __webpack_require__ (/private/var/root/vepo/dist/server/index.js:27:30)
    at /private/var/root/vepo/dist/server/index.js:93:18
Waiting for the debugger to disconnect...

似乎您在同一端口上运行了两个应用程序。E3000。

使用此命令

netstat -tulpn

显示服务器上的所有过程,然后将kill与进程ID一起使用。像kill processid

最新更新