I have an application written in electron and nodejs that I am trying to run. It uses the module portscanner to check for an open port in a particular range:
portscanner.findAPortNotInUse(3000, 3010, '127.0.0.1', function(error, port) {
console.log("Free port: " + port)
})
However, I am getting this error:
RangeError: "port" argument must be >= 0 and < 65536
at assertPort (internal/net.js:17:11)
at Server.listen (net.js:1389:5)
Even though the range I have is clearly less than 65536 and greater than 0.
Looking online, it seems to be an error in node v6 (I have v6.5.0). I am new to nodejs, and would greatly appreciate any help regarding how to fix this. Thanks.
It's an issue with newer versions of node.
https://github.com/FWeinb/nodeshot/issues/11
It was also raised as an issue on the electron project.
For quickly handle it you can also use try.....catch
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With