get-unused-port const getUnusedPort = require('get-unused-port') getUnusedPort().then(port => { // Use the port...})