fallback-port
get an available port and preventing eaddrinuse error.
If multiple applications running same port then you will get the below error (Error: listen EADDRINUSE)
.
This module will give you an available port and kill other processes.
This module covered Mac OSX and Windows.
Install
$ npm install fallback-port
API
getPid
Finding the PID from default port.
return pid number or null.
getPort
Tries return a random available port if the requested port is taken
kill
Find and kill process locking port.
Example
var port = 8080; var fallbackPort = 8080; //return pid number or nullvar pid = fallbackPort; //return available portvar otherPort = fallbackPort; ifotherPort != port console //kill processfallbackPort;