{"id":17840,"library":"node-opcua-service-register-node","title":"node-opcua Service Register Node","description":"The `node-opcua-service-register-node` package is a module within the comprehensive `node-opcua` SDK, a pure Node.js and TypeScript implementation of the OPC UA specification. The SDK is designed for building high-performing asynchronous applications, leveraging Node.js's capabilities. It adheres to a 'Perpetual Beta' model, with new enhanced versions released approximately every two weeks, ensuring continuous improvement and community testing. The project emphasizes quality with over 3500 unit tests and 93% code coverage. This specific module primarily defines the data structures and message types for the OPC UA RegisterNodes Service, which allows OPC UA clients to register NodeIds with a server for more efficient, repeated access operations. The current stable version of the `node-opcua` ecosystem is 2.169.0.","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-register-node","lang":"bash","label":"npm"},{"cmd":"yarn add node-opcua-service-register-node","lang":"bash","label":"yarn"},{"cmd":"pnpm add node-opcua-service-register-node","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM is the preferred module system. This type defines the structure for registering nodes with an OPC UA server.","wrong":"const RegisterNodesRequest = require('node-opcua-service-register-node').RegisterNodesRequest;","symbol":"RegisterNodesRequest","correct":"import { RegisterNodesRequest } from 'node-opcua-service-register-node';"},{"note":"This type defines the expected response structure from an OPC UA server after a RegisterNodes request.","wrong":"const RegisterNodesResponse = require('node-opcua-service-register-node').RegisterNodesResponse;","symbol":"RegisterNodesResponse","correct":"import { RegisterNodesResponse } from 'node-opcua-service-register-node';"},{"note":"While used by the RegisterNodes service, fundamental types like NodeId are typically imported from the core `node-opcua` package, not individual service modules.","wrong":"import { NodeId } from 'node-opcua-service-register-node';","symbol":"NodeId","correct":"import { NodeId } from 'node-opcua';"}],"quickstart":{"code":"import { OPCUAServer, OPCUAClient, MessageSecurityMode, SecurityPolicy, UserTokenType, NodeId, resolveNodeId } from 'node-opcua';\nimport { RegisterNodesRequest, RegisterNodesResponse } from 'node-opcua-service-register-node';\n\nasync function startOpcUaExample() {\n  // 1. Setup a simple OPC UA Server\n  const server = new OPCUAServer({\n    port: 4334,\n    resourcePath: '/UA/MyServer',\n    buildInfo: {\n      productName: 'MySampleServer',\n      buildNumber: '1234',\n      buildDate: new Date()\n    }\n  });\n\n  await server.initialize();\n  const addressSpace = server.engine.addressSpace;\n  if (!addressSpace) { throw new Error('AddressSpace not initialized'); }\n\n  const device = addressSpace.getFolder('ObjectsFolder')?.addFolder({\n    browseName: 'MyDevice'\n  });\n\n  if (device) {\n    device.addVariable({\n      browseName: 'Temperature',\n      nodeId: 's=TemperatureSensor1',\n      dataType: 'Double',\n      value: { get: () => new Variant({ dataType: DataType.Double, value: 25.5 }) }\n    });\n    console.log('Server initialized with a Temperature variable.');\n  }\n  \n  await server.start();\n  console.log(`Server is running at ${server.endpoints[0]?.endpointDescriptions()[0]?.endpointUrl}`);\n\n  // 2. Setup a simple OPC UA Client and demonstrate RegisterNodesRequest structure\n  const client = OPCUAClient.create({\n    endpointUrl: server.endpoints[0]?.endpointDescriptions()[0]?.endpointUrl,\n    securityMode: MessageSecurityMode.None,\n    securityPolicy: SecurityPolicy.None,\n    connectionStrategy: { maxRetry: 0 }\n  });\n\n  try {\n    await client.connect(server.endpoints[0]?.endpointDescriptions()[0]?.endpointUrl ?? '');\n    console.log('Client connected to server.');\n\n    const session = await client.createSession({\n      userIdentity: { type: UserTokenType.Anonymous }\n    });\n    console.log('Client session created.');\n\n    // Create a RegisterNodesRequest (this package provides the type definition)\n    const nodesToRegister = [\n      resolveNodeId('s=TemperatureSensor1'),\n      new NodeId('ns=1;s=AnotherNode') // Example of another node\n    ];\n    \n    const registerRequest = new RegisterNodesRequest({\n      nodesToRegister: nodesToRegister\n    });\n\n    console.log('Constructed RegisterNodesRequest:', JSON.stringify(registerRequest.toJSON(), null, 2));\n    \n    // In a real client, you would send this request via session.performMessage or similar:\n    // const response: RegisterNodesResponse = await session.registerNodes(registerRequest.nodesToRegister);\n    // console.log('RegisterNodes response:', response);\n\n    await session.close();\n    await client.disconnect();\n    console.log('Client disconnected.');\n\n  } catch (err) {\n    console.error('Client error:', err);\n  } finally {\n    await server.shutdown();\n    console.log('Server shut down.');\n  }\n}\n\nstartOpcUaExample().catch(console.error);\n","lang":"typescript","description":"This quickstart demonstrates how to set up a minimal `node-opcua` server and client, and then shows how to construct a `RegisterNodesRequest` object using types provided by this package for registering NodeIds with the server to optimize subsequent access."},"warnings":[{"fix":"Review custom codebases for direct dependencies or deep integrations with `node-opcua` internals that might have used `async` or `lodash`. Update code to use native JavaScript asynchronous patterns and utilities.","message":"Version 2.168.0 introduced a full migration of core packages from older `async` and `lodash` utilities to native modern JavaScript patterns. This may cause breaking changes in applications that directly relied on or extended `node-opcua`'s internal use of these libraries.","severity":"breaking","affected_versions":">=2.168.0"},{"fix":"Upgrade to v2.165.0 or newer. Review any code paths that use `setValueFromSource()` with extension objects and verify data integrity after the update.","message":"In version 2.165.0, a bug was fixed where calling `setValueFromSource()` on a `UAVariable` containing a bound extension object with `Date`, `NodeId`, `QualifiedName`, `LocalizedText`, `DiagnosticInfo`, or array fields could lead to silent data corruption.","severity":"breaking","affected_versions":">=2.165.0"},{"fix":"Ensure your clients and servers are configured to use modern security policies like `Aes256_Sha256_RsaPss`. If backward compatibility is strictly required, explicitly specify the older security policies in the `OPCUAServer` constructor's `securityPolicies` parameter.","message":"Version 2.123.0 removed `Basic128Rsa15` and `Basic256` as default security policies for the OPC UA server, making `Aes256_Sha256_RsaPss` the new default. Clients or servers configured to exclusively use the deprecated policies without explicit configuration will fail to connect.","severity":"breaking","affected_versions":">=2.123.0"},{"fix":"When running Node.js applications using `node-opcua` on affected Node.js versions, include the `--security-revert=CVE-2023-46809` flag in the Node.js command line arguments.","message":"Node.js versions newer than 18.11.1 or 20.11.1 require a special flag (`--security-revert=CVE-2023-46809`) to re-enable PKCS1 padding due to its reintroduction in `node-opcua` v2.123.0. Without this flag, cryptographic operations requiring PKCS1 padding may fail.","severity":"gotcha","affected_versions":">=2.123.0"},{"fix":"Ensure that both OPC UA client and server machines have their system clocks accurately synchronized (e.g., using NTP). While the client can now use its own time for token renewal, clock discrepancies are a common source of connection issues and should be resolved.","message":"Version 2.123.0 introduced improved clock synchronization checks. Clients will now log a warning (`[NODE-OPCUA-W33]`) in the console if a significant time discrepancy is detected between the client and server clocks, which can affect security token renewal and lead to disconnections.","severity":"gotcha","affected_versions":">=2.123.0"},{"fix":"Carefully manage certificate generation, private keys, and trust lists. Always verify that your certificate chains are correctly installed and trusted by both client and server. Stay updated with `node-opcua-pki` and `node-opcua-crypto` versions to ensure compatibility with your Node.js and OpenSSL environment.","message":"The OPC UA SDK, including its certificate management (v2.164.2, v2.167.0) and crypto libraries (v2.165.2+), frequently evolves to address security and compatibility. OpenSSL 3.5+ compatibility updates in v2.165.2+ are crucial for newer Node.js versions. Incorrect certificate handling is a common pitfall.","severity":"gotcha","affected_versions":">=2.164.2"}],"env_vars":null,"last_verified":"2026-04-23T00:00:00.000Z","next_check":"2026-07-22T00:00:00.000Z","problems":[{"fix":"Ensure the package is installed: `npm install node-opcua` or `npm install node-opcua-service-register-node`. Verify correct import paths in your code.","cause":"The 'node-opcua' package or its sub-modules are not installed or incorrectly referenced.","error":"Cannot find module 'node-opcua'"},{"fix":"Ensure 'node-opcua' is installed. TypeScript types are bundled with the library, so a correct installation should resolve this. Check your `tsconfig.json` for `moduleResolution` settings.","cause":"TypeScript compiler cannot locate the type definitions for the 'node-opcua' package.","error":"error TS2307: Cannot find module 'node-opcua'."},{"fix":"Synchronize the system clocks of both the client and server machines using Network Time Protocol (NTP) or similar methods to ensure accurate timekeeping.","cause":"There is a significant time difference between the OPC UA client and server machines.","error":"[NODE-OPCUA-W33] client : server token creation date exposes a time discrepancy of [...] the remote server clock doesn't match this computer date !"},{"fix":"Use a non-privileged port (e.g., 4334 as in the quickstart) or ensure the process has the necessary permissions to bind to the desired port.","cause":"The server attempted to listen on a privileged port (e.g., below 1024 on Linux) or a port already in use, without sufficient permissions.","error":"OPCUA Server failed to start: Error: EACCES: permission denied, listen 0.0.0.0:4840"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}