@ fibjs / detect-port
端口检测器JavaScript实现
安装
$ npm i @fibjs/detect-port --save
用法
const detectPort = require ( '@fibjs/detect-port' ) ;
const availablePort = detectPort ( ) ;
或者
const detectPort = require ( '@fibjs/detect-port' ) ;
const port = 3000 ;
const availablePort = detectPort ( port ) ;
if ( availablePort === port ) {
console . log ( `port ${ port } is available!` ) ;
} else {
console
1