{"id":13636,"library":"node-opcua-service-node-management","title":"node-opcua-service-node-management","description":"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.","status":"active","version":"2.169.0","language":"javascript","source_language":"en","source_url":"git://github.com/node-opcua/node-opcua","tags":["javascript","OPCUA","opcua","m2m","iot","opc ua","internet of things","typescript"],"install":[{"cmd":"npm install node-opcua-service-node-management","lang":"bash","label":"npm"},{"cmd":"yarn add node-opcua-service-node-management","lang":"bash","label":"yarn"},{"cmd":"pnpm add node-opcua-service-node-management","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Primarily used for defining new nodes to be added to the server's address space. Part of the Node Management Service Set request types.","wrong":"const { AddNodesItem } = require('node-opcua-service-node-management');","symbol":"AddNodesItem","correct":"import { AddNodesItem } from 'node-opcua-service-node-management';"},{"note":"Represents an item to be deleted from the server's address space. Ensure correct named import.","wrong":"import DeleteNodesItem from 'node-opcua-service-node-management';","symbol":"DeleteNodesItem","correct":"import { DeleteNodesItem } from 'node-opcua-service-node-management';"},{"note":"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.","wrong":"import { NodeClass } from 'node-opcua-service-node-management';","symbol":"NodeClass","correct":"import { NodeClass } from 'node-opcua-nodeset-ua';"}],"quickstart":{"code":"import { OPCUAServer, Variant, DataType, NodeId, ReferenceTypeIds, QualifiedName } from 'node-opcua';\nimport { AddNodesItem, NodeClass } from 'node-opcua-service-node-management';\n\nasync function createServerAndAddNode() {\n  const server = new OPCUAServer({\n    port: 4334,\n    resourcePath: 'UA/MyNodeManagementServer',\n    buildInfo: {\n      productName: 'MyNodeManagementServer',\n      buildNumber: '7658',\n      buildDate: new Date()\n    }\n  });\n\n  await server.initialize();\n\n  const addressSpace = server.engine.addressSpace;\n  if (!addressSpace) {\n    throw new Error('AddressSpace not initialized');\n  }\n\n  // Add a custom namespace\n  const namespace = addressSpace.registerNamespace('http://mynamespace.com/UA/Demo/');\n  console.log('Registered Namespace Index:', namespace.index);\n\n  // Add a new folder node programmatically using AddNodesItem\n  const folderBrowseName = new QualifiedName({ name: 'MyDynamicFolder', namespaceIndex: namespace.index });\n  const folderNodeId = new NodeId('s=MyDynamicFolder', namespace.index);\n\n  const addFolderItem: AddNodesItem = new AddNodesItem({\n    parentNodeId: addressSpace.getFolderId('Objects') || new NodeId('i=85'), // Objects folder\n    referenceTypeId: ReferenceTypeIds.Organizes,\n    requestedNewNodeId: folderNodeId,\n    browseName: folderBrowseName,\n    nodeClass: NodeClass.Object,\n    nodeAttributes: {\n      displayName: { text: 'My Dynamic Folder' },\n      description: { text: 'A folder created dynamically' }\n    }\n  });\n\n  // In a real application, you would invoke the AddNodes service with these items.\n  // For a server adding nodes to its own address space, direct `addressSpace.addNode` is often used,\n  // but this demonstrates the structure of AddNodesItem.\n  // For simplicity, we'll demonstrate what the internal `addNode` might receive, or how a client would send it.\n\n  const newFolder = addressSpace.addFolder(addFolderItem.parentNodeId, addFolderItem.browseName.name);\n  newFolder.setNodeId(addFolderItem.requestedNewNodeId);\n  console.log(`Dynamically added folder: ${newFolder.browseName.toString()} (NodeId: ${newFolder.nodeId.toString()})`);\n\n  await server.start();\n  console.log(`Server is now listening on ${server.endpoints[0].endpointUrl}`);\n  console.log('Press Ctrl+C to stop the server.');\n\n  process.on('SIGINT', async () => {\n    await server.shutdown();\n    console.log('Server shut down.');\n    process.exit(0);\n  });\n}\n\ncreateServerAndAddNode().catch(console.error);\n","lang":"typescript","description":"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."},"warnings":[{"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.","message":"Version 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.","severity":"breaking","affected_versions":">=2.168.0"},{"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) => { ... }`.","message":"The `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.","severity":"gotcha","affected_versions":">=2.167.0"},{"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.","message":"Maintaining 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.","severity":"gotcha","affected_versions":">=2.159.0"},{"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.","message":"When 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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'1.05':90 '2.169.0':54 'activ':45 'ad':62 'address':39,146 'advanc':109 'advertis':113 'build':137 'cadenc':73 'capabl':105 'certif':103 'complianc':91 'compon':18 'core':17 'current':51 'data':96 'delet':64 'deploy':110 'develop':46,135 'differenti':85 'docker/nat':116 'dynam':143 'ecosystem':50 'enabl':134 'endpoint':114 'environ':117 'essenti':28 'everi':81 'expos':121 'featur':77 'full':87 'handl':56,98 'improv':80 'includ':86 'internet':155 'iot':152 'javascript':148 'key':84 'layer':101 'librari':68 'like':112 'm2m':151 'maintain':69 'manag':6,13,33,104,131 'messag':126 'modifi':144 'modul':119 'new':76 'node':2,5,9,12,34,48,65,130 'node-opcua':47 'node-opcua-service-node-manag':1,8 'node.js':22 'opc':23,37,58,88,138,153 'opcua':3,10,49,149,150 'optim':94 'packag':14 'part':42 'perform':93 'programmat':66 'provid':26 'pure':21 'rapid':71 'releas':72,75 'request':123 'respons':125 'robust':102 'scenario':111 'sdk':25 'server':140 'servic':4,11,60,132 'set':133 'signific':92 'space':40,147 'specif':120 'stabil':79 'stabl':52 'structur':29 'support':107 'thing':157 'transport':100 'type':31,97,127 'typescript':158 'typic':74 'ua':24,38,59,89,139,154 'version':53 'week':83 'within':35","created_at":"2026-04-20T01:55:31.890770+00:00","updated_at":"2026-04-20T01:55:31.890770+00:00","problems":[{"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.","cause":"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.","error":"OPC UA Service Fault: Bad_ServiceUnsupported"},{"fix":"Use the correct `NodeAttributes` subclass, e.g., `new ObjectAttributes({ displayName: { text: 'My Object' } })` for `NodeClass.Object`.","cause":"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.","error":"Error: NodeAttributes instance must be of the correct subtype for the specified NodeClass."},{"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.","cause":"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`).","error":"TS2307: Cannot find module 'node-opcua-service-node-management'."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":"https://node-opcua.github.io/","github":"https://github.com/node-opcua/node-opcua","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/node-opcua-service-node-management","openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking","serialization","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}