npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@0biwank/gethwid

v1.0.3

Published

Get Hardware ID (HWID) of the machine using a native Node.js addon built with N-API.

Readme

getHWID

A native Node.js module for retrieving hardware identification information on Windows systems. This module uses N-API to access Windows WMI (Windows Management Instrumentation) and system firmware data.

Features

  • CPU Serial: Get the processor ID from CPU
  • Disk Serial: Retrieve the serial number of physical storage devices
  • Motherboard Serial: Fetch motherboard serial number
  • MAC Address: Get the network adapter's MAC address
  • Built with N-API for native access
  • Includes TypeScript definitions

Requirements

  • Node.js: >= 14.0.0
  • Platform: Windows (Win32) only
  • Build Tools: Python 3.x and C++ compiler (for building from source)

Installation

npm install @0biwank/gethwid

Usage

JavaScript (ESM)

import { getCPUSerial, getDiskSerial, getMotherboardSerial, getMacAddress } from '@0biwank/gethwid';

// Get CPU Serial
const cpuSerial = getCPUSerial();
console.log('CPU Serial:', cpuSerial);

// Get Disk Serial
const diskSerial = getDiskSerial();
console.log('Disk Serial:', diskSerial);

// Get Motherboard Serial
const mbSerial = getMotherboardSerial();
console.log('Motherboard Serial:', mbSerial);

// Get MAC Address
const macAddress = getMacAddress();
console.log('MAC Address:', macAddress);

JavaScript (CommonJS with default export)

import getHWID from '@0biwank/gethwid';

const cpu = getHWID.getCPUSerial();
const disk = getHWID.getDiskSerial();
const mb = getHWID.getMotherboardSerial();
const mac = getHWID.getMacAddress();

console.log({ cpu, disk, mb, mac });

TypeScript

import { getCPUSerial, getDiskSerial, getMotherboardSerial, getMacAddress } from '@0biwank/gethwid';

const cpuSerial: string = getCPUSerial();
const diskSerial: string = getDiskSerial();
const mbSerial: string = getMotherboardSerial();
const macAddress: string = getMacAddress();

console.log({
  cpu: cpuSerial,
  disk: diskSerial,
  motherboard: mbSerial,
  mac: macAddress
});

API Reference

getCPUSerial(): string

Returns the processor ID from the CPU.

Returns: A string containing the CPU processor ID.

Example:

const cpu = getCPUSerial();

getDiskSerial(): string

Returns the serial number of the primary physical disk/storage device.

Returns: A string containing the disk serial number.

Example:

const disk = getDiskSerial();

getMotherboardSerial(): string

Returns the serial number of the motherboard/baseboard.

Returns: A string containing the motherboard serial number.

Example:

const mb = getMotherboardSerial();

getMacAddress(): string

Returns the MAC (Media Access Control) address of the primary network adapter.

Returns: A string containing the MAC address in standard notation (XX:XX:XX:XX:XX:XX).

Example:

const mac = getMacAddress();

How It Works

This module uses:

  1. Windows WMI (Windows Management Instrumentation) for CPU, disk, and motherboard information
  2. System Firmware Table (via GetSystemFirmwareTable) for system UUID and detailed hardware info
  3. N-API for seamless integration between Node.js and native C++ code

Building from Source

If you need to rebuild the module:

# Install dependencies
npm install

# Rebuild the native addon
npm run rebuild

Prerequisites for Building

  • Node.js with development headers
  • Python 3.x
  • Microsoft Visual Studio (Community Edition is sufficient) with C++ workload

Testing

Run the test suite:

npm test

This will execute test.js and display hardware information for your system.

Limitations

  • Windows Only: This module only works on Windows systems (Win32)
  • Administrator Privileges: Some information may require elevated privileges
  • Virtual Machines: Virtualized environments may return virtual hardware identifiers
  • Dual Boot: Only detects hardware of the current Windows installation

Error Handling

Functions return empty strings if hardware information cannot be retrieved:

const cpuSerial = getCPUSerial();

if (!cpuSerial) {
  console.warn('Could not retrieve CPU serial');
} else {
  console.log('CPU:', cpuSerial);
}

Performance

All functions execute synchronously and typically complete quickly by accessing system information through WMI queries.

License

MIT © Kunal Dubey

Repository

GitHub: 0biwank/getHWID

Contributing

Contributions and bug reports are welcome. Please open an issue or submit a pull request on GitHub.

Disclaimer

This module retrieves hardware identification information for legitimate purposes such as:

  • System administration
  • License key generation
  • Device identification for software activation
  • Hardware inventory management

Users are responsible for complying with applicable laws and privacy regulations when using hardware identification data.