node-localip

Simple tool that gives you the local, prefered (default/active) IPv4 addresse.

Usage no npm install needed!

<script type="module">
  import nodeLocalip from 'https://cdn.skypack.dev/node-localip';
</script>

README

node-localip

Simple tool that gives you the local, prefered (default/active) IPv4 addresses.

Install

As a command line tool

$ (sudo) npm install node-localip -g

As a node module:

$ npm install node-localip

Usage

Command line:

$ localip
10.58.100.191
$

Node module:

var getLocalIp = require( "node-localip" );

getLocalIp( function ( err, ip ) {
    console.log( err || ip );
} );

... or, list all local IPv4 addresses with the prefered as the first ...

getLocalIp.list( function ( err, ipList ) {
    console.log( err || ipList );
} );

License

MIT