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 🙏

© 2026 – Pkg Stats / Ryan Hefner

winreg-native

v1.0.5

Published

Native node.js module for interacting with Windows Registry

Readme

winreg-native

Native Node.js binding for ultra-fast Windows Registry access.

Highlights

  • Native C++ binding built with node-gyp and nan.
  • Dramatic speed improvements over JS-based solutions (claimed 250x–5600x faster depending on operation).
  • Promise-first API with synchronous Sync variants for blocking operations.
  • One callback-based method: watchValue for change notifications.

Table of contents

  1. Installation & build
  2. Quick start
  3. API reference
  4. Types & conversions
  5. Examples
  6. Building / contributing
  7. Troubleshooting
  8. License & credits

Installation & build

Install from npm

npm install winreg-native

This module contains native code and must be built for the target Node.js version and platform (Windows only).

  1. Ensure you have a working Windows build environment and Node.js development toolchain (Python, Visual Studio Build Tools, node-gyp).
  2. Add the module source to your project or install it as a dependency.
  3. Install nan (used by the native code) if not bundled: npm install --save nan.

Typical local build steps from the module root:

npm install        # install JS deps (if present)
node-gyp configure
node-gyp build

Quick start

const winreg = require('winreg-native');

(async () => {
  const v = await winreg.getValue(winreg.HKLM, 'SOFTWARE\\MyApp', 'InstallPath');
  console.log('InstallPath =', v);
})();

API reference

Constants

The module exports hive constants:

  • HKLM — HKEY_LOCAL_MACHINE
  • HKCU — HKEY_CURRENT_USER
  • HKCR — HKEY_CLASSES_ROOT
  • HKU — HKEY_USERS
  • HKCC — HKEY_CURRENT_CONFIG

Async methods (Promise)

All async methods return a Promise.

  • getValue(hive, key, value)String | Number | BigInt | Buffer | Array<string>
  • setValue(hive, key, value, data)Boolean
  • deleteValue(hive, key, value)Boolean
  • deleteKey(hive, key)Boolean
  • deleteTree(hive, key)Boolean
  • enumerateKeys(hive, key)String[]
  • enumerateValues(hive, key)Object mapping { valueName: convertedValue }

All have synchronous counterparts with Sync suffix.


Synchronous methods (blocking)

Identical signatures to async methods but block the event loop and return directly.


watchValue (callback-based)

watchValue(hive, key, value, callback)

  • Watches for changes to a registry value.
  • callback(err, value)value is converted per Types & conversions.

Types & conversions

From Registry → JS (ConvertRegistryValue):

  • REG_DWORDNumber (unsigned 32-bit)
  • REG_QWORDBigInt (signed 64-bit)
  • REG_BINARYBuffer
  • REG_MULTI_SZArray<string>
  • REG_SZ, REG_EXPAND_SZString
  • Fallback/default → String (raw data interpreted as UTF-8)

From JS → Registry (ConvertJsValue):

  • StringREG_SZ
  • BooleanREG_DWORD (0 or 1)
  • BigIntREG_QWORD if lossless 64-bit, else REG_SZ (string form)
  • Number
    • REG_DWORD if fits in unsigned 32-bit
    • REG_QWORD if fits in signed 64-bit
    • otherwise REG_SZ (string form)

Important:

  • Booleans are always written as REG_DWORD (0/1) and will be read back as Number, not as true/false.
  • Large numbers beyond JS safe integer range will be returned as BigInt.

Examples

Read a value (async/await)

const path = await winreg.getValue(winreg.HKLM, 'SOFTWARE\\MyCompany\\MyApp', 'InstallPath');
console.log('InstallPath:', path);

Set a value

await winreg.setValue(winreg.HKCU, 'Software\\MyApp', 'Enabled', true);

Watch a value

winreg.watchValue(winreg.HKCU, 'Software\\MyApp', 'CurrentVersion', (err, value) => {
  if (err) return console.error(err);
  console.log('new value:', value);
});

Synchronous usage

const v = winreg.getValueSync(winreg.HKLM, 'SOFTWARE\\MyApp', 'InstallPath');
console.log(v);

Troubleshooting

  • Booleans not returned as booleans — expected behavior; interpret 0/1 manually.
  • Binary data — returned as Buffer.
  • Build errors — ensure MSVC Build Tools & node-gyp are set up.