Open ajayashuba opened 5 years ago
@ajayashuba Its been months, have you got any solution? I really need to know! I'm using ionic 4
For all the recent and future readers, you can use https://github.com/doppiaQ/cordova-plugin-portfinder
Then start the webserver like that:
portfinder.getPort().then((port) => {
webserver.start(
function() {
console.log("Started the HTTP server on port ", port);
},
function() {
console.log('Failed to start the HTTP server');
},
port
)
}).catch((e) => {
console.log("Failed to find a free port");
});
how do i make sure the port is not used by any other instance if i choose port by myself there is some % chance that that port might be in use ..is there way to programatically access the free port given by the system