import os from "os" function getLocalIPv(ver = 4) { const ips = [] const inter = os.networkInterfaces() // console.dir(inter, { depth: null }) for (let net in inter) { // console.dir(net, { depth: null }) // console.log() for (let netPort of inter[net]) { // netPort = inter[net][netPort] // console.dir(netPort, { depth: null }) if (netPort.family === `IPv${ver}`) { // console.dir(netPort, { depth: null }) ips.push(netPort.address) } } } // console.log() // console.dir(ips, { depth: null }) return ips } export { getLocalIPv }