node-opcua is a comprehensive, pure JavaScript/TypeScript implementation of the OPC Unified Architecture (OPC UA) stack, designed for Node.js environments. It enables the creation of OPC UA clients, servers, and related tools, facilitating machine-to-machine (M2M) and Industrial IoT (IIoT) communication. The package is actively maintained, with frequent minor and patch releases, currently stable at version 2.169.0, focusing on performance, memory optimization, and OPC UA 1.05 compliance. Key differentiators include its full adherence to the OPC UA specification, a robust architecture for handling large information models, and enterprise-grade support and value-added extensions provided by Sterfive SAS, which also sponsors its long-term development. It supports modern Node.js versions (>=18) and ships with TypeScript types for improved developer experience.
npm install node-opcuaVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to set up a basic OPC UA server, expose a dynamically updating integer variable, and then connect to it with an OPC UA client to browse its address space and read the variable's value. It uses anonymous authentication and no message security for simplicity. For production use, secure communication with certificates and user authentication is highly recommended.
Upgrade your Node.js runtime environment to version 18 or newer. Consider using an LTS version for stability.
Review your codebase for direct dependencies on `async` or `lodash` utilities implicitly provided by older `node-opcua` versions. Adapt code to use native JavaScript alternatives or explicitly import `async`/`lodash` if still needed.
Consult the `node-opcua-pki` release notes for detailed API changes. Migrate certificate handling code to the new, more robust API, especially regarding trust list management and PFX files. The `TrustListClient.addCertificate` method now accepts full certificate chains.
For client applications, update the `securityPolicy` to `SecurityPolicy.Aes256_Sha256_RsaPss` or ensure it matches the server's configured policy. Server applications can explicitly define `securityPolicies` in the constructor to re-enable older policies if compatibility is required.
If encountering issues with PKCS1 padding on newer Node.js versions, add `--security-revert=CVE-2023-46809` to your Node.js command line. Evaluate the security implications of this revert for your application.
For advanced use cases, comprehensive support, or commercial extensions, consider applying for the NodeOPCUA Subscription at https://support.sterfive.com or contacting Sterfive SAS.
Carefully configure `advertisedEndpoints` in your server settings to reflect the externally accessible IP address and port. Refer to the official documentation for detailed guidance on Docker/NAT deployment scenarios.
Migrate your project or the specific file to use ES Module `import` syntax (`import { Name } from 'node-opcua';`). Ensure your `package.json` has `"type": "module"` if using `.js` files for ESM, or use `.mjs` extensions.For development, set `securityMode: MessageSecurityMode.None` and `securityPolicy: SecurityPolicy.None` (if applicable) or `allowAnonymous: true` on the server. For production, generate valid certificates from a trusted CA, ensure all certificates in the chain are in the respective trust lists, or utilize a Global Discovery Server (GDS) for certificate management.
Verify the OPC UA server is running and listening on the specified port. Double-check the client's `endpointUrl` for correctness. Ensure no firewall rules (local or network) are blocking TCP traffic on the server's port. For Docker/NAT, ensure advertised endpoints are correctly configured.
Delete the auto-generated certificate files (typically found in `C:\Users\user\AppData\Roaming\node-opcua-default-nodejs` on Windows or `~/.config/node-opcua-default-nodejs` on Linux) and restart the server to regenerate them with the correct host information. For custom certificates, ensure the certificate's subject alternative names (SANs) or common name (CN) match the server's application URI and hostname.