How to grab the computer name with NodeJs / Electron?

You can use the standard nodeJS os API to retrieve the (host)name of a computer, see this API documentation for more details.

const computerName = os.hostname()

On a Mac the only way to reliably get the "ComputerName" as OP requested is to use a child process, which isn't ideal...

cp.execSync('scutil --get ComputerName')

Most of the time hostname will === ComputerName, but I found out the hard way today that this is not always the case.