const portfinder = require('portfinder')
module.exports = new Promise((resolve, reject) => {
portfinder.getPort(
{
port: 8080, // 默认8080端口,若被占用,重复+1,直到找到可用端口或到stopPort才停止
stopPort: 65535, // maximum port
},
(err, port) => {
if (err) {
reject(err)
return
}
devWebpackConfig.devServer.port = port
resolve(devWebpackConfig)
}
)
})
标签:8080,端口,maximum,portfinder,stopPort,port
From: https://www.cnblogs.com/longmo666/p/18092212