npm install --save find-open-port
const findPort = require('find-open-port');
findPort().then(port => {
console.log(`You may now start listening on %d.${port}`);
});
findPort.isAvailable(80).then(available => {
console.log(`Port 80 is ${available ? 'available' : 'not available'}`);
});