
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
libmodbusjs
Advanced tools
libmodbusjs is a high-performance Node.js library for Modbus communication built on top of the native libmodbus C library. It is implemented as a Node.js C++ addon, providing low-level access to Modbus RTU and TCP interfaces with the efficiency of native code and the simplicity of JavaScript.
libmodbus under the hood.This library uses precompiled binaries specific to your OS and Node.js version.
Before using, please visit the latest releases and ensure there is a .tar.gz file matching your:
If your version is not available, npm install libmodbusjs may attempt to rebuild the addon and fail if required tools (like a C++ compiler or libmodbus) are missing.
npm install libmodbusjs
All methods are exposed through the Modbus class. You first instantiate a Modbus object, set the slave address, connect, then read/write as needed.
new Modbus(mode: 'rtu' | 'tcp', options: object)
mode: Either 'rtu' or 'tcp'options:
path: Serial port path (e.g. /dev/ttyUSB0)baudRate: Baud rate (e.g. 9600)ip: Device IPport: Port (default: 502)connect() → booleanEstablishes the Modbus connection.
Returns true if successful, throws error otherwise.
close()Closes the current Modbus connection and frees native memory.
setSlave(id: number) → booleanSets the slave address.
getSlave() → numberReturns the currently set slave address.
readRegisters(startAddr: number, count: number) → number[]Reads a sequence of holding registers.
startAddr: Starting register addresscount: Number of registers to readwriteRegister(addr: number, value: number) → booleanWrites a single value to a register.
writeRegisters(startAddr: number, values: number[]) → booleanWrites multiple values starting from a specific address.
import Modbus from 'libmodbusjs';
const modbus = new Modbus('rtu', { path: '/dev/ttyUSB0', baudRate: 9600 });
modbus.setSlave(1);
modbus.connect();
const values = modbus.readRegisters(0, 4);
console.log('Register values:', values);
modbus.writeRegister(0, 42);
modbus.close();
import Modbus from 'libmodbusjs';
const modbus = new Modbus('tcp', { ip: '192.168.0.10', port: 502 });
modbus.setSlave(1);
modbus.connect();
const values = modbus.readRegisters(10, 2);
console.log(values);
modbus.writeRegisters(10, [100, 200]);
modbus.close();
FAQs
A modbus protocol which is a C++ node addon
We found that libmodbusjs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.