I made an installation of node-opcua and buffer, but when i tried to run the code:
import { useEffect, useState } from ‘react’
import reactLogo from ‘./assets/react.svg’
import viteLogo from ‘/vite.svg’
import ‘./App.css’
import { OPCUAClient } from “node-opcua”;
import { Buffer } from “buffer”;
const PLC_ADDRESS = “opc.tcp://172.16.90.1:4840”; // OPC UA endpoint URL
const nodeIdInt = ‘ns=3;s=“DB1”.int’; // Node ID for the value to read
const nodeIdBool = ‘ns=3;s=“DB1”.int’; // Node ID for the value to read
const client = new OPCUAClient();
…
i got always error about buffer, refering to line code:
const client = new OPCUAClient();
The console returns the errors:
client.ts:112 ReferenceError: Buffer is not defined
at node_modules/node-opcua-buffer-utils/dist/buffer_utils.js (buffer_utils.ts:14:46)
at __require2 (chunk-OROXOI2D.js?v=89588ab7:16:50)
at node_modules/node-opcua-buffer-utils/dist/index.js (index.ts:4:1)
at __require2 (chunk-OROXOI2D.js?v=89588ab7:16:50)
at node_modules/node-opcua-basic-types/dist/byte_string.js (byte_string.ts:5:1)
at __require2 (chunk-OROXOI2D.js?v=89588ab7:16:50)
at node_modules/node-opcua-basic-types/dist/index.js (index.ts:8:1)
at __require2 (chunk-OROXOI2D.js?v=89588ab7:16:50)
at node_modules/node-opcua-types/dist/_generated_opcua_types.js (_generated_opcua_types.ts:14:1)
at __require2 (chunk-OROXOI2D.js?v=89588ab7:16:50)