Node.js for LJM - Windows, Mac, Linux | LabJack
« Close

Datasheets and User Guides

App Notes

Software & Driver


Node.js for LJM - Windows, Mac, Linux

LJM Node.js Examples Windows, Mac, Linux (Software Platform)

Node.js examples for the LJM library. The source code for the LJM Node.js library is also available on GitHub and npm.


LJM Nodejs Examples Top (Referenceable)

Known Issues

LJM stream functions do not work.


  • LabJack T7 or T4
  • LJM Library - Install the LJM Library
  • Node.js and npm.
  • Operating system - Windows, Mac OS X, or Linux.
  • The ability to compile node.js native modules. Look at the ffi and node-gyp for more details.

LJM Examples Where Is An Example To Do XYZ Minimal (Referencable)

Communication Basics

With the LJM library, pretty much everything you might want to do with a device is accomplished by writing and/or reading some registers.  Look at the device's datasheet (T7 or T4) or the Modbus Map to determine what registers you need to write and read, then use eWriteName (or eWriteNames) to write the desired registers and eReadName (or eReadNames) to read the desired registers.

LJM Nodejs Examples Bottom (Referenceable)


  1. Go to the T4 or T7 Quickstart Tutorial and follow the steps to install LabJack software and confirm basic operation.
  2. Download and extract or clone the git repository and navigate into the directory.
  3. Execute "npm install" to install all of the project's dependencies. This will automatically compile the ffi library.
  4. Execute "cd examples" to navigate into the examples directory.
  5. Execute "node hello_world.js" to run the hello world example.

Including ljm-ffi into your own node.js project

  1. Open Windows command prompt/power shell, or Mac/Linux bash window.
  2. Navigate into your node.js project.
  3. Execute "npm install ljm-ffi".

Further Reading:

Look at the ljm-ffi git repository for more information.

Code Snippet

// Load the LJM Library.
var ljm_ffi = require('../lib/ljm-ffi');
var ljm = ljm_ffi.load();

// Load a utility function to get the connected device's info.
var utils = require('./utils/utils');
var getHandleInfoSync = utils.getHandleInfoSync;

// Define a variable that will store data from LJM function calls
var data;

// Define a variable that will store the device's handle.
var handle;

// Open the first found T7.
data = ljm.LJM_OpenS('LJM_dtT7', 'LJM_ctANY', 'LJM_idANY', 0);

// Exit the program if a device was not found.
if(data.ljmError !== 0) {
	console.log('Failed to open a device, please connect a T7 to your computer.');
} else {
	handle = data.handle;
	console.log('Connected to device:', getHandleInfoSync(handle));

// Read the T7's AIN0.
data = ljm.LJM_eReadName(handle, 'AIN0', 0);
console.log('AIN0', data.Value);

// Close the device.
data = ljm.LJM_Close(handle);

File list contains: