JavaScript Implementation of Port Detector
$ npm i @fibjs/detect-port --save
const detectPort = require('@fibjs/detect-port');
const availablePort = detectPort();
or
const detectPort = require('@fibjs/detect-port');
const port = 3000;
const availablePort = detectPort(port);
if (availablePort === port) {
console.log(`port ${port} is available!`);
} else {
console.log(`port ${port} is not available! Got a random available port: ${availablePort} for you.`);
}
Please open an issue here.