var npm = require('getmac');//获取mac地址 var macAddressStr = ""; //获取机器mac地址 npm.getMac(function(err,macAddress){ if (err) throw err; macAddressStr = macAddress; //获取mac地址 console.log(macAddressStr); }); console.info(macAddressStr);