node-portfinder
2024-10-21 06:11:31
nstallation
$ [sudo] npm install portfinder
Usage
var portfinder = require('portfinder'); portfinder.getPort(function (err, port) {
//
// `port` is guaranteed to be a free port
// in this scope.
//
});
Promise形式
const portfinder = require('portfinder'); portfinder.getPortPromise()
.then((port) => {
//
// `port` is guaranteed to be a free port
// in this scope.
//
})
.catch((err) => {
//
// Could not get a free port, `err` contains the reason.
//
});
Ports search scope
By default portfinder
will start searching from 8000
and scan until maximum port number (65535
) is reached.
You can change this globally by setting:
portfinder.basePort = 3000; // default: 8000
portfinder.highestPort = 3333; // default: 65535
默认端口从8000扫描到65535,上面两个方法可以i实现自定义扫描范围
or by passing optional options object on each invocation:
portfinder.getPort({
port: 3000, // minimum port
stopPort: 3333 // maximum port
}, callback);
最新文章
- 【菜鸟学习jquery源码】数据缓存与data()
- win10 MySQL启动失败问题
- MD5加密算法实现用户信息加密
- LeetCode Flip Game
- Socket状态变迁图
- 创建immutable类
- Android MVPR 架构模式
- 解决IE6下png图片不透明
- ImageMagick的使用
- hdu 1232畅通工程
- protobuf 参考资料
- 破解.net程序 编译和反编译方法
- hdu2089(数位dp)
- PDF解决方案(3)--PDF转SWF
- elasticsearch文档-analysis
- LeetCode - 728. Self Dividing Numbers
- 【一天一道LeetCode】#64. Minimum Path Sum.md
- asp.net core session丢失问题排查
- 启用k8s metrics server监控
- MVC5 Entity Framework学习
热门文章
- Linux下查看文件内容的命令和工具
- linux 上安装多个不同版本的mysql 踩的坑
- Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.thinkplatform.dao.UserLogDao' available: expected at least 1 bean which qualifies as autowi
- 没错,老板让我写个 BUG!
- springboot~mybatis里localdatetime序列化问题
- C# net request payload形式发送post请求
- Python两步实现关联规则Apriori算法,参考机器学习实战,包括频繁项集的构建以及关联规则的挖掘
- python实现某目录下将多个文件夹内的文件复制到一个文件夹中
- PLSQL 登录出现 ora12638 credential retrieval failed
- win10安装tensorflow-gpu1.13.1+cuda10.0+cudnn7.3.1