Registry / http-networking / node-opcua-service-node-management

node-opcua-service-node-management

JSON →
library2.169.0jsnpmunverified

The `node-opcua-service-node-management` package is a core component of the pure Node.js OPC UA SDK, providing the essential structures and types for managing nodes within an OPC UA Address Space. As part of the actively developed `node-opcua` ecosystem (current stable version 2.169.0), it handles the OPC UA services for adding and deleting nodes programmatically. The library maintains a rapid release cadence, typically releasing new features and stability improvements every few weeks. Key differentiators include full OPC UA 1.05 compliance, significant performance optimizations in data type handling and transport layers, robust certificate management capabilities, and support for advanced deployment scenarios like advertised endpoints for Docker/NAT environments. This module specifically exposes the request and response message types for the Node Management Service Set, enabling developers to build OPC UA servers that can dynamically modify their address space.

npm install node-opcua-service-node-management
INSTALL
IMPORT
SIG · NODE-OPCUA-SERVICE
N
node-opcua-service-node-management
http-networkingjavascriptv2.169.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AddNodesItem
import { AddNodesItem } from 'node-opcua-service-node-management';
const { AddNodesItem } = require('node-opcua-service-node-management');
Primarily used for defining new nodes to be added to the server's address space. Part of the Node Management Service Set request types.
DeleteNodesItem
import { DeleteNodesItem } from 'node-opcua-service-node-management';
import DeleteNodesItem from 'node-opcua-service-node-management';
Represents an item to be deleted from the server's address space. Ensure correct named import.
NodeClass
import { NodeClass } from 'node-opcua-nodeset-ua';
import { NodeClass } from 'node-opcua-service-node-management';
Core OPC UA types like NodeClass, NodeId, Variant, DataType are generally imported from 'node-opcua-nodeset-ua' or 'node-opcua-types' for clarity and version compatibility within the broader node-opcua ecosystem.

This quickstart demonstrates how to initialize an OPC UA server and use `AddNodesItem` to define and add a new folder node to its address space dynamically. It illustrates the structure for client-initiated node creation requests.

import { OPCUAServer, Variant, DataType, NodeId, ReferenceTypeIds, QualifiedName } from 'node-opcua'; import { AddNodesItem, NodeClass } from 'node-opcua-service-node-management'; async function createServerAndAddNode() { const server = new OPCUAServer({ port: 4334, resourcePath: 'UA/MyNodeManagementServer', buildInfo: { productName: 'MyNodeManagementServer', buildNumber: '7658', buildDate: new Date() } }); await server.initialize(); const addressSpace = server.engine.addressSpace; if (!addressSpace) { throw new Error('AddressSpace not initialized'); } // Add a custom namespace const namespace = addressSpace.registerNamespace('http://mynamespace.com/UA/Demo/'); console.log('Registered Namespace Index:', namespace.index); // Add a new folder node programmatically using AddNodesItem const folderBrowseName = new QualifiedName({ name: 'MyDynamicFolder', namespaceIndex: namespace.index }); const folderNodeId = new NodeId('s=MyDynamicFolder', namespace.index); const addFolderItem: AddNodesItem = new AddNodesItem({ parentNodeId: addressSpace.getFolderId('Objects') || new NodeId('i=85'), // Objects folder referenceTypeId: ReferenceTypeIds.Organizes, requestedNewNodeId: folderNodeId, browseName: folderBrowseName, nodeClass: NodeClass.Object, nodeAttributes: { displayName: { text: 'My Dynamic Folder' }, description: { text: 'A folder created dynamically' } } }); // In a real application, you would invoke the AddNodes service with these items. // For a server adding nodes to its own address space, direct `addressSpace.addNode` is often used, // but this demonstrates the structure of AddNodesItem. // For simplicity, we'll demonstrate what the internal `addNode` might receive, or how a client would send it. const newFolder = addressSpace.addFolder(addFolderItem.parentNodeId, addFolderItem.browseName.name); newFolder.setNodeId(addFolderItem.requestedNewNodeId); console.log(`Dynamically added folder: ${newFolder.browseName.toString()} (NodeId: ${newFolder.nodeId.toString()})`); await server.start(); console.log(`Server is now listening on ${server.endpoints[0].endpointUrl}`); console.log('Press Ctrl+C to stop the server.'); process.on('SIGINT', async () => { await server.shutdown(); console.log('Server shut down.'); process.exit(0); }); } createServerAndAddNode().catch(console.error);
Debug
Known issues
breakingVersion 2.168.0 introduced a significant internal migration from `async` and `lodash` libraries to native modern JavaScript patterns. While not explicitly listed as breaking, changes of this nature to core packages can impact users who relied on specific internal behaviors or older asynchronous patterns, potentially requiring code adjustments for compatibility or unexpected runtime errors.
fix
Review your code for reliance on deprecated `async` or `lodash` utilities if you encounter unexpected behavior. Ensure your Node.js environment is up-to-date with versions supporting modern JavaScript features.
affects: >=2.168.0
gotchaThe `ApplyChanges` event chain in version 2.167.0 now threads `ISessionContext` through. Event handlers for configuration changes might need to be updated to accept and process this additional context, which allows identifying the session that triggered a modification.
fix
Update `ApplyChanges` event listeners to include `ISessionContext` in their function signature if you wish to leverage or avoid issues with the new context parameter. Example: `(item: any, context: ISessionContext) => { ... }`.
affects: >=2.167.0
gotchaMaintaining the server's Node.js environment is crucial for security. Recent versions (e.g., v2.159.0) include security upgrades to the base Node.js runtime (e.g., 20.19.6-bookworm-slim). Running on older, unpatched Node.js versions can expose your OPC UA server to known vulnerabilities.
fix
Regularly update your Node.js runtime environment to the latest stable and patched versions. Pay attention to security advisories for both `node-opcua` and Node.js itself.
affects: >=2.159.0
gotchaWhen implementing client-side node management, ensuring the server has `setNodeManagementEnabled(true)` (or equivalent) is vital. Many OPC UA servers, by default, do not allow dynamic node additions/deletions from clients for security reasons, resulting in a `Bad_ServiceUnsupported` exception.
fix
On the OPC UA server, explicitly enable node management capabilities if you intend for clients to dynamically modify the address space. Consult the server's specific configuration or `node-opcua`'s server setup documentation.
affects: All versions
Errors
Common errors & fixes
OPC UA Service Fault: Bad_ServiceUnsupported
The OPC UA server does not have its node management capabilities enabled, or the connected user lacks the necessary permissions to perform node addition/deletion services.
fix
Ensure that `server.engine.addressSpace.setNodeManagementEnabled(true);` (or similar for other SDKs) is called during server initialization and that the client's user identity has appropriate access rights.
Error: NodeAttributes instance must be of the correct subtype for the specified NodeClass.
When creating an `AddNodesItem`, the `nodeAttributes` property must be an instance of the specific `NodeAttributes` subtype (e.g., `ObjectTypeAttributes`, `VariableAttributes`, `ObjectAttributes`) corresponding to the `nodeClass` you are trying to add, not the generic `NodeAttributes` base class.
fix
Use the correct `NodeAttributes` subclass, e.g., `new ObjectAttributes({ displayName: { text: 'My Object' } })` for `NodeClass.Object`.
TS2307: Cannot find module 'node-opcua-service-node-management'.
The TypeScript compiler or runtime cannot locate the package. This usually indicates an incorrect import path, missing `node_modules` installation, or an issue with TypeScript configuration (e.g., `paths` in `tsconfig.json`).
fix
Verify that `node-opcua-service-node-management` is listed in your `package.json` and installed (`npm install` or `pnpm install`). Check the import statement for typos and ensure your `tsconfig.json` correctly resolves modules.
Upgrade
Version history
2.169.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
node-opcua-service-node-management — npm install node-opcua-service-node-management · libregistry