Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Mac OS computer name in nodejs

For windows it's console.log(process.env['COMPUTERNAME']);

But how to do it for Mac OS?

like image 266
Mary Avatar asked Feb 08 '23 15:02

Mary


1 Answers

Try the os-module:

var os = require('os')
console.log(os.hostname())

This is the best way to get the hostname.

like image 67
PatrickD Avatar answered Feb 11 '23 15:02

PatrickD