在 sails 中调试时监听 EADDRINUSE 错误

Listen EADDRINUSE error while debugging in sails

我正在尝试使用 node-inspector 调试我的代码,但我的终端 window 一次又一次地收到此错误

$ sudo sails debug
info: Running app in debug mode...
info: You probably want to install / run node-inspector to help with debugging!
info: https://github.com/node-inspector/node-inspector

info: ( to exit, type <CTRL>+<C> )

    Error: listen EADDRINUSE
        at exports._errnoException (util.js:746:11)
        at Agent.Server._listen2 (net.js:1156:14)
        at listen (net.js:1182:10)
        at Agent.Server.listen (net.js:1267:5)
        at Object.start (_debugger_agent.js:20:9)
        at startup (node.js:86:9)
        at node.js:814:3

解决

Error : listen EADDRINUSE

我试过关闭其他终端window(我的节点检查器是运行)。 我提到了 answers already here on Whosebug 但它们没有用 我什至试过给出这个命令来终止进程:

$ killall -9 node 
No matching processes belonging to you were found

但仍然无法正常工作。 有人请帮我解决这个问题。

我看到您正在使用 sudo,所以这不是权限问题。

看来端口确实已被使用。您应该 check to see which process is using the port,然后终止该进程。

有一个 known issue with using sails debug on Node v12.0. There's a patch 将与下一版本的 Sails (v0.12) 一起发布。

在此期间,您可以 install the edge version of Sails from Github or apply the patch yourself by replacing your Sails' /lib/hooks/grunt/index.js file with the contents of https://raw.githubusercontent.com/balderdashy/sails/88ffc0ed9949f8c74ea390efb5610b0e378fa02c/lib/hooks/grunt/index.js

首先,找到使用端口 1337 的任务:

netstat -ano | findstr : 1337 (port number)

然后杀掉它:

tskill (process ID (PID))

可以解决你的问题