{"library":"network-interfaces","title":"Network Interface Utilities for Node.js","description":"The `network-interfaces` package provides synchronous utility functions for retrieving and filtering network interface and IP address information in Node.js. It acts as a wrapper around Node.js's built-in `os.networkInterfaces()` method, offering simplified functions like `toIp`, `toIps`, `fromIp`, `getInterface`, and `getInterfaces` with optional filtering by internal status and IP version (IPv4/IPv6). The current stable version is 1.1.0, last published in 2017. Due to its age and lack of maintenance, it is considered abandoned. Users are encouraged to directly use `os.networkInterfaces()` or seek more actively maintained alternatives for robust network interface management in modern Node.js applications, especially if TypeScript support or ESM compatibility is required.","language":"javascript","status":"abandoned","last_verified":"Tue Apr 21","install":{"commands":["npm install network-interfaces"],"cli":null},"imports":["const ni = require('network-interfaces');"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const ni = require('network-interfaces');\n\ntry {\n  // Get all IPv4 external interface names\n  const externalIpv4Interfaces = ni.getInterfaces({\n    internal: false,\n    ipVersion: 4\n  });\n  console.log('External IPv4 Interfaces:', externalIpv4Interfaces);\n\n  if (externalIpv4Interfaces.length > 0) {\n    const firstInterfaceName = externalIpv4Interfaces[0];\n    // Get the first IPv4 address for a specific interface\n    const firstIpv4 = ni.toIp(firstInterfaceName, { ipVersion: 4 });\n    console.log(`First IPv4 address for ${firstInterfaceName}:`, firstIpv4);\n\n    // Get the interface name from an IP address (e.g., localhost)\n    const loopbackInterface = ni.fromIp('127.0.0.1');\n    console.log('Interface for 127.0.0.1:', loopbackInterface);\n  } else {\n    console.log('No external IPv4 interfaces found.');\n  }\n\n} catch (error) {\n  console.error('An error occurred:', error.message);\n}","lang":"javascript","description":"This quickstart demonstrates how to use `network-interfaces` to find external IPv4 interface names, retrieve an IP address for a given interface, and determine an interface name from a specific IP address, including error handling.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}