freeport-es6 Find a free TCP-port Install npm install freeport-es6 --save Usage import freeport from "freeport-es6"; async function getPort(){ try{ const port = await freeport(); console.log(port); }catch(e){ console.error(e); } } Test npm install npm test