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

opcua-snapshot

v1.0.4

Published

[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/do-/node-opcua-snapshot)

Downloads

13

Readme

Ask DeepWiki

node-opcua-snapshot is a Node.js library that enables snapshot-based management of OPC UA server address spaces. It provides two primary capabilities:

  • Extraction: Connect to an existing OPC UA server and capture its address space structure, node configurations, and relationships into a portable JSON format
  • Recreation: Load a JSON snapshot and populate a new OPC UA server with the captured configuration

The library acts as a configuration management layer on top of the node-opcua protocol implementation, enabling use cases such as:

  • Creating test servers with production-like configurations
  • Version-controlling OPC UA server structures
  • Cloning servers across different environments
  • Building mock servers for offline development

Installation

npm install opcua-snapshot

Usage

Taking a Snapshot from an Existing Server

const fs            = require ('node:fs')
const {OPCUAClient} = require ('node-opcua')
const {Dumper}      = require ('opcua-snapshot')

async function dump (filePath, endpointUrl, rootNode) {

    const client = OPCUAClient.create ({endpointMustExist: false})

    try {

        await client.connect (endpointUrl)

        const session = await client.createSession ()

        const dumper = new Dumper (session)

        // dumper.on ('start',   _ => console.log (_))
        // dumper.on ('warning', _ => console.log (_))
        // dumper.on ('finish', _  => console.log ('finish'))

        const snapshot = await dumper.dump (rootNode /* ?? {ns: 0, i: 85}*/) // `Objects` by default

        fs.writeFileSync (filePath, JSON.stringify (snapshot, null, 2))

    }
    finally {

        await client.disconnect ()

    }

}

Using a Saved Snapshot to run a New Server


const fs                         = require ('node:fs')
const {OPCUAServer, StatusCodes} = require ('node-opcua')
const {Loader}                   = require ('opcua-snapshot')

// mock history data
const MS_IN_DAY     = 1000 * 60 * 60 * 24
const values = [0.0], dates = [(new Date (new Date ().toJSON ().substring (0, 10) + 'T00:00:00')).getTime ()]
for (let i = 0; i < 10; i ++) {
    values.push (values [i] + Math.random ())
    dates.unshift (dates [0] - MS_IN_DAY)
}

async function run (fn, port) {

    const server = new OPCUAServer ({endpoints: [{port}]})

    await server.initialize ()                      // prior to creating the Loader

    const loader = new Loader (server)

    loader.on ('var', varNode => {                  // will adjust variables upon creation:
        if (!varNode.historizing) return            // for historical ones (in this example)...
        varNode.accessLevel = 4                     // ... only allow HistoryRead
        loader.setValues (varNode, values, dates)   // ... and set the generated values
    })

    loader.on ('method', varMethod => {
        varMethod.bindMethod ((args, _, callback) => {
            console.log (args)
            callback (null, {statusCode: StatusCodes.Good})
        })
    })
    
    loader.load (JSON.parse (fs.readFileSync (fn))) // actually load the configuration

    await server.start ()

    loader.setValue ('ns=1;s=MyObj.MyProp', '1234') // at run time

}

See Also

More documentaion available at https://deepwiki.com/do-/node-opcua-snapshot