Reputation: 31
I am running ubuntu in vmware. I am trying to get the baseboard serial number.
var si = require("systeminformation");
console.log(si.baseboard().serial);
It return undefined. Is the problem in my code? Or the problem is ubuntu is running in vmware?
Upvotes: -1
Views: 1548
Reputation: 31
I find that I can use serial-number to get an unique number even on virtual machine.
var serialNumber = require('serial-number');
serialNumber(function (err, value) {
console.log(value);
});
Upvotes: 0
Reputation: 5941
To complete AKX answer, si.baseboard()
returns a Promise (since v3), so you have to do something like this:
si.baseboard().then(el => console.log(el.serial))
or, if you want to stick with callback syntax
si.baseboard(el => { console.log(el.serial) })
Note for me, it returns an empty string if I launch the script as a regular user. I can display the serial number only if I launch it as root.
Upvotes: 0
Reputation: 169338
You can see here in the systeminformation
source that it's reading the file /sys/devices/virtual/dmi/id/board_serial
(if running dmidecode -t 2 2>/dev/null
fails).
If you cat /sys/devices/virtual/dmi/id/board_serial
in your shell (if it even exists), what do you get?
If it's empty or non-existent, then the data isn't provided by your environment.
Upvotes: 0