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

@amigo9090/opcda-node

v0.0.3

Published

OPC DA 2.0 wrapper for Node.js using N-API

Readme

opcda-node

A Node.js native addon (N-API) for OPC DA (Data Access) 2.0 communication on Windows x64.
It allows reading, writing, and subscribing to OPC items from any OPC DA 2.0 server.

This addon is built with node-gyp, provides prebuilt binaries for Windows x64, and requires OPC Core Components (or the target OPC server's runtime) to be installed.


✨ Features

  • OPC DA 2.0 protocol support (IOPCServer, IOPCItemMgt, IOPCSyncIO, IOPCAsyncIO2, IOPCDataCallback)
  • Synchronous group & item managementcreateGroup, addItem, subscribe, unsubscribe
  • Asynchronous read/writeread and write return Promise, executed in background threads
  • Real‑time data change notifications – subscribe to OPC groups, receive dataChange events
  • Browse server address space – list all available item IDs
  • Easy‑to‑use event‑driven API – single callback for all events (connect, disconnect, dataChange)
  • Prebuilt binaries for Windows x64 – no compilation required on target machines (if OPC Core Components are present)

🖥️ Supported Platform

| Operating System | Architecture | Prebuilt binary | |-----------------|--------------|-----------------| | Windows | x64 | ✅ yes |

Note: Only Windows x64 is supported. The addon uses COM/DCOM and OPC DA 2.0 interfaces, which are available only on Windows.


🚀 Installation

Prerequisites

  1. Node.js 18 or higher (tested with Node 20).

  2. OPC Core Components (or the runtime provided by your OPC server).
    You can download the official redistributable from the OPC Foundation or install it together with your OPC server (e.g. OPC Simulator).

    If OPC Core Components are missing, the addon may fail to create COM objects.

  3. No C++ compiler required on the target machine – prebuilt binary is included.

Install from npm

npm install @amigo9090/opcda-node

📖 Usage
Basic example

const opcda = require('@amigo9090/opcda-node');

const client = new opcda.OPCDA((event) => {
    console.log('Event:', event.type, event.data);

    if (event.type === 'connect') {
        if (event.data.success) {
            console.log('✅ Connected to OPC server!');
            // Create group, add items, subscribe...
            client.createGroup('Group1', 1000, 0.0);
            client.addItem('Group1', 'Random.Int1');
            client.subscribe('Group1');   // subscribe to data changes
        } else {
            console.error('Connection failed:', event.data.error);
        }
    } else if (event.type === 'dataChange') {
        console.log('Data change:', event.data);
    } else if (event.type === 'disconnect') {
        console.log('Disconnected');
    }
});

client.connect('localhost', 'OPC.Simulator.1');

API methods
Method	Description
connect(host, progId)	Synchronous – connects to an OPC DA server (e.g. OPC.Simulator.1). Result is reported via the connect event.
disconnect()	Synchronous – closes the connection.
createGroup(groupName, updateRate, deadband)	Synchronous – creates a group.
addItem(groupName, itemName)	Synchronous – adds an item to a group.
subscribe(groupName)	Synchronous – enables async data change notifications for the group.
unsubscribe(groupName)	Synchronous – disables async notifications.
read(itemName)	Asynchronous – returns a Promise that resolves with the current value.
write(itemName, value)	Asynchronous – returns a Promise that resolves when the write is complete.
browse(startingItem)	Asynchronous – returns a Promise that resolves with an array of all item IDs.
Events
The constructor callback receives an event object with a type field:

connect – event.data.success (boolean), event.data.error (if failed)

disconnect – event.data is an empty object

dataChange – event.data is an object where keys are item names and values are their current values.

🔧 Building from source (optional)
If you need to rebuild the addon (e.g., for debugging or custom modifications):

git clone https://github.com/Amigo909090/ih-opcda-node.git
cd ih-opcda-node
npm install
npm run build

Requirements:

Windows 10/11, Visual Studio 2022 (with C++ development tools and ATL/MFC)

Python 3.11

Node.js 18+

OPC Core Components (already installed)

📚 Additional Examples
See the examples/ folder for more complete usage scenarios.

🤝 Contributing
Contributions are welcome!

Fork the repository.

Create a feature branch.

Submit a pull request with a clear description of your changes.

Please open an issue first to discuss major changes.

📜 License
This project is licensed under the MIT License – see the LICENSE file for details.

💬 Support
For bugs, questions, or feature requests, please use the GitHub Issues page.