Node server snooping error problem

server.on("error", onError);

if an error Error: listen EADDRINUSE: 4000 indicates that port 4000 is occupied, how can I use code execution to close the application that kills the currently occupied port if I hear that EADDRINUSE, does not enter the command line or task management in the onError event?

Apr.26,2021

  1. netstat-ano | findstr 4000 query the PID; occupied by port 4000
  2. assume 3015;
  3. taskkill / pid 3015
Menu