开发者

Node.js - Forbid declaration of specific TCP port and use a variable instead (a la Cloud9)

开发者 https://www.devze.com 2023-04-12 19:32 出处:网络
I\'m sharing开发者_JS百科 a server to develop Node.js apps with others and I want to forbid the declaration of a specific port and instead use a var/function to assign an unused port from a pool.

I'm sharing开发者_JS百科 a server to develop Node.js apps with others and I want to forbid the declaration of a specific port and instead use a var/function to assign an unused port from a pool.

I'm aware that Cloud9 implements this functionality as they force the use of a variable to set up the port (e.g. When specifically declaring the port, it replies with "Error: Port not allowed, please use 'process.env.C9_PORT' as port and '0.0.0.0' as host."), however, I don't want to install Cloud9 and even if I wanted to, it doesn't works as it does on their website, also, it allows the use of a specific port.

What can I do to force the use of a var instead of the declaration of specific ports? Is there a Node.js module already doing this? Can anyone please try to help me in this?

Thank you all in advance!


Yes, there is a node.js module that does this - portfinder

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号