electronjs - how can I get mac address of the machine

Viewed 2169

I am building a desktop app using electronjs. I want to be able to identify a machine uniquely. I believe it should be ok to use mac address of the machine as unique identifier. I don't know how to get mac address of the machine. Couldn't find any good example on internet. Appreciate all the help.

Thank you.

1 Answers

I am new to electronjs (and nodejs too), so this is main reason I find getting things done difficult. Thank you @Brettski for suggestions in the comments. Following commands and script worked for me:

  1. Installed getmac in my local electronjs project folder, by running this command.
    npm install --save getmac

  2. In the JavaScript created getmac variable by importing getmac module
    const getmac = require('getmac')

  3. Ready to use, by invoking it's default function:
    console.log(getmac.default())

    I couldn't successfully run getMAC() function, but default() worked. I guess, I need to understand what args to pass etc.

Related