node-hardware
v2.0.0
Published
bbtain computer hardware information
Readme
Supported Platforms
- windows(ia32/x64)
- Linux(x64/arm64/loong64)
Supported for use in
electron.
Obtain computer hardware information:
- CPU
- Hard Drive
- MAC Address
Installation
npm install --save node-hardwareExamples
CPU Information
const hardware = require("node-hardware");
console.log(hardware.getCpuinfo());Result
{
arch: 'x64',
vendor: 'GenuineIntel',
model: 'Intel(R) Core(TM) i9-14900K',
cpuid: 'BFCBFBFF000B0671'
}If the architecture is Linux x64, you can pass the argument false to not return the cpuid information.
Real MAC Address
const hardware = require("node-hardware");
console.log(hardware.getMacAddress());Result
[ 'D8:43:AE:16:3E:BB' ]Hard Drive Information
const hardware = require("node-hardware");
console.log(hardware.getDiskInformation());Result
[
{
no: 0,
isSystem: false,
productId: 'KINGSTON SV300S...',
productRevision: '608A...',
sn: '50026B7...'
},
{
no: 1,
isSystem: false,
productId: 'ST1000DM003...',
productRevision: 'CC...',
sn: '......W4Y1ZCWQ'
},
{
no: 2,
isSystem: true,
productId: 'ZHITAI ...',
productRevision: 'ZTA...',
sn: '0000_0000_0000_0000_...'
},
{
no: 3,
isSystem: false,
productId: 'WDC WD...',
productRevision: '211070...',
sn: 'E823_8FA6_BF53_0001_...'
}
]The field
isSystemindicates whether the current disk is the system disk.
In Linux, only the disk information of types
sdandnvmehas been obtained.
Licensing
If your process name is node.exe or electron.exe, your use will be unrestricted. Otherwise, you need to purchase a License to use it.
const hardware = require("node-hardware");
console.log(hardware.setLicense("..."));If the License is valid, it will return true.
Note: Authorization is required only when it is necessary to invoke functions within the
addon, such as information that can be obtained fromfssys, and is not required when calling the interface.
Addon Installation
Starting from version 2.0, the required addon files must be downloaded manually. The following APIs have been added to manage the downloading and configuration of the addon path.
- setAddonDirectory(path) - Sets the directory path for the addon files.
- getAddonDirectory() - Retrieves the current addon directory path.
- existsAddon() - Checks if the current addon file exists.
- loadAddon() - Loads the addon based on the configured path.
- download(options) - Downloads the addon file for the current platform.
Please refer to the source files for specific parameter details.
