{"id":17307,"library":"node-opcua-nodeset-ua","title":"Node-OPCUA Standard NodeSets","description":"The `node-opcua-nodeset-ua` package is a core component of the `node-opcua` SDK, providing the standard OPC UA NodeSet XML definitions. These definitions are essential for building OPC UA servers that expose a semantically rich address space conforming to the OPC UA Unified Architecture specification. As part of the highly active `node-opcua` monorepo, it receives frequent updates, typically bi-weekly, aligning with the project's 'Perpetual Beta' model. The current stable version is 2.169.0. Key differentiators for the `node-opcua` ecosystem, including this module, include its pure Node.js implementation, extensive TypeScript support, and a focus on industrial IoT (IIoT) and Machine-to-Machine (M2M) communication. It allows developers to load standard and custom information models into an OPC UA server's address space for robust data exposure.","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-nodeset-ua","lang":"bash","label":"npm"},{"cmd":"yarn add node-opcua-nodeset-ua","lang":"bash","label":"yarn"},{"cmd":"pnpm add node-opcua-nodeset-ua","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This named import provides the XML string for the core OPC UA NodeSet (version 2). It is commonly used to initialize an OPC UA server's address space. `node-opcua` is primarily an ESM-first library with TypeScript definitions.","wrong":"const standardNodeSet2 = require('node-opcua-nodeset-ua').StandardNodeSet2;","symbol":"standardNodeSet2","correct":"import { standardNodeSet2 } from 'node-opcua-nodeset-ua';"},{"note":"Provides the filesystem path to the `Opc.Ua.NodeSet2.xml` file, useful when `loadUAModel` or similar functions expect a file path instead of the content itself.","symbol":"standardNodeSet2Filename","correct":"import { standardNodeSet2Filename } from 'node-opcua-nodeset-ua';"},{"note":"Imports all exports from the `node-opcua-nodeset-ua` module as a namespace, allowing access to various NodeSet versions or utilities if exposed. For example, `nodesets.standardNodeSet2`.","symbol":"nodesets","correct":"import * as nodesets from 'node-opcua-nodeset-ua';"}],"quickstart":{"code":"import { OPCUAServer } from 'node-opcua-server';\nimport { standardNodeSet2 } from 'node-opcua-nodeset-ua';\n\nasync function main() {\n  // Create an OPC UA Server instance\n  const server = new OPCUAServer({\n    port: 4840, // Default OPC UA port\n    resourcePath: '/UA/MyNodeSetServer',\n    buildInfo: {\n      productName: 'NodeSet Example Server',\n      buildNumber: '1',\n      buildDate: new Date(),\n    },\n  });\n\n  // Initialize the server\n  await server.initialize();\n  console.log('Server initialized.');\n\n  // Load the standard OPC UA NodeSet (version 2) into the server's address space\n  // The `standardNodeSet2` export provides the XML content as a string.\n  await server.loadUAModel({\n    nodeset_filename: [standardNodeSet2], // Pass the NodeSet XML string here\n  });\n  console.log('Standard NodeSet2 loaded.');\n\n  // Optionally, extend the address space with custom objects or variables\n  const addressSpace = server.engine.addressSpace;\n  if (addressSpace) {\n    const objectsFolder = addressSpace.getFolder('ObjectsFolder');\n    const myDeviceFolder = objectsFolder?.addFolder({\n      browseName: 'MyCustomDevices',\n      displayName: 'My Custom Devices',\n    });\n    myDeviceFolder?.addVariable({\n      browseName: 'Temperature',\n      dataType: 'Double',\n      value: { get: () => new server.variant({ dataType: server.DataType.Double, value: 25.5 }) },\n    });\n  }\n  console.log('Custom objects added to address space.');\n\n  // Start the server\n  await server.start();\n  console.log(`Server is now listening on port ${server.port}`);\n  console.log(`Server discovery URL: ${server.getEndpointUrl()}`);\n  console.log('Press Ctrl+C to stop the server.');\n\n  // Handle server shutdown on SIGINT\n  process.on('SIGINT', async () => {\n    console.log('Shutting down server...');\n    await server.shutdown();\n    console.log('Server shut down.');\n    process.exit(0);\n  });\n}\n\nmain().catch(console.error);","lang":"typescript","description":"Demonstrates how to set up a basic OPC UA server and load the standard NodeSet 2.0 information model using `node-opcua-nodeset-ua` to establish a foundational address space."},"warnings":[{"fix":"Review custom code and plugins for direct dependencies on `async` or `lodash` utilities. Refactor to use native JavaScript asynchronous patterns (e.g., `Promise`, `async/await`) and built-in array/object methods.","message":"Version 2.168.0 introduced a full migration of core packages from `async`/`lodash` to native modern JavaScript patterns. While primarily internal, this could affect users with custom plugins or extensions that directly relied on the removed third-party utilities, potentially causing breaking changes in their integrations.","severity":"breaking","affected_versions":">=2.168.0"},{"fix":"Validate custom NodeSet XML files and DataType definitions against OPC UA 1.05 specifications. Test existing server implementations thoroughly to ensure data types are correctly recognized and handled, especially for complex structures and unions. Consult the `node-opcua` documentation for updated guidance on custom DataType registration.","message":"With version 2.163.0, `node-opcua` finalized full support for OPC UA 1.05 subtyped structures and unions, coupled with a major overhaul of DataType handling. This significant change might cause issues for existing custom DataType definitions or information models that were implicitly relying on older, less compliant parsing behaviors.","severity":"breaking","affected_versions":">=2.163.0"},{"fix":"Review and update certificate management logic in clients and servers. Ensure that `TrustListClient.addCertificate` is used correctly with certificate chains if applicable. Familiarize yourself with the `OPCUACertificateManager` API and best practices for secure certificate handling, including proper PKI setup and trusted/rejected certificate store management.","message":"Certificate management APIs have undergone architectural overhauls and enhancements across several recent versions (e.g., v2.167.0, v2.164.2). Changes to `TrustListClient.addCertificate` and the `OPCUACertificateManager` API, including support for certificate chains, mean that older or non-standard certificate handling logic might behave unexpectedly or require updates.","severity":"gotcha","affected_versions":">=2.164.2"},{"fix":"When deploying `node-opcua` servers in containerized or proxied environments, explicitly configure the `advertisedEndpoints` option in the `OPCUAServer` constructor to reflect the externally accessible URLs. This ensures clients receive the correct network information for connection. ","message":"Introduced in v2.165.0, 'Advertised Endpoints' are crucial for correct operation in environments like Docker, behind NAT, or reverse proxies. Failure to properly configure advertised endpoints will lead to clients being unable to connect or discover the server correctly, as the internal network address may be exposed instead of the external one.","severity":"gotcha","affected_versions":">=2.165.0"},{"fix":"Ensure that both OPC UA client and server machines have their system clocks synchronized, ideally using NTP (Network Time Protocol). Address any `[NODE-OPCUA-W33]` warnings by rectifying time discrepancies to prevent potential connection instability.","message":"The `node-opcua` client (since v2.123.0) now displays a warning `[NODE-OPCUA-W33]` if a significant time discrepancy (over 5 seconds) exists between the client and server clocks. While not strictly a breaking error, significant time differences can lead to security token renewal issues and unexpected disconnections in secure channels.","severity":"gotcha","affected_versions":">=2.123.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Convert your project or specific files to ES Modules by adding `\"type\": \"module\"` to your `package.json` or by using `.mjs` file extensions. Then, use `import { standardNodeSet2 } from 'node-opcua-nodeset-ua';` syntax. If a mixed environment is required, consider dynamic `import()` or a build step to transpile to CommonJS if strictly necessary.","cause":"Attempting to use `require()` to import `node-opcua-nodeset-ua` or other `node-opcua` modules in a CommonJS context, while the library is primarily designed for ES Modules.","error":"ERR_REQUIRE_ESM: require() of ES Module ... not supported"},{"fix":"Ensure the peer's certificate (or its Certificate Authority's certificate) is correctly placed in the `trusted/certs` directory of your client's/server's PKI store. For self-signed certificates, both sides typically need to trust the other's certificate. Verify certificate dates and revocation status. `node-opcua` provides tools (e.g., `node-opcua-pki`) to manage certificates.","cause":"The OPC UA client or server has received a certificate from its peer that is not present in its trusted certificate store (PKI/trusted/certs folder) or is otherwise invalid/untrusted.","error":"Bad_SecurityChecksFailed: The X.509 certificate is not trusted."},{"fix":"Verify the exact symbol name and the import path. The common import is `import { standardNodeSet2 } from 'node-opcua-nodeset-ua';`. Check the `node-opcua-nodeset-ua` package for available exports in your installed version. If using older `node-opcua` versions, the export name or module structure might differ.","cause":"The `standardNodeSet2` symbol (or similar NodeSet export) is either misspelled, or the import statement is incorrect, or the module structure has changed in an unexpected version.","error":"Cannot find name 'standardNodeSet2'."},{"fix":"Double-check the file path provided to `nodeset_filename`. Ensure the XML file is valid and correctly formatted, typically UTF-8 encoded, and accessible by the Node.js process. Tools like XML validators can help diagnose malformed files.","cause":"The NodeSet XML file provided to `server.loadUAModel()` is either missing, has an incorrect path, or contains malformed XML that prevents parsing. This can also occur if the file is ASCII-encoded when UTF-8 is expected.","error":"[node-opcua] Cannot load nodeset '...' : file not found or invalid XML format."}],"ecosystem":"npm","meta_description":null}