Latest node-red-contrib-modbus is not working - Fix, needs ssh

The latest version of Modbus package (node-red-contrib-modbus) is not working. The Modbus-tcp package does work, but doesn’t do well with having multiple connections to multiple slaves.

Most people will install node-red-contrib-modbus. With some research and testing, it doesn’t matter what firmware release you are using for the EPIC. It is module issue.
More info: TypeError: Cannot read property `registerForModbus` of null · Issue #134 · BiancoRoyal/node-red-contrib-modbus · GitHub

To fix it, you will need shell access.

Once you login to your EPIC via SSH:
Use the following command:

cd /home/dev/.node-red/node_modules
sudo npm install -g node-red-contrib-modbus@4.1.1
Enter your password, and it will install the previous working version.
Restart Node-Red (https://your.ip/manage/local/node-red), Disable, Enable

Now you have a working version of the modbus client.

Dan

2 Likes

Over 4 years later, and the forum topic is still relevant, so I figure I would keep this thread going.

Last week I updated EPIC #1 to 3.5.1-b.85 which includes Node-RED v3.0.2 & Node.js version v14.20.0. I use node-red-contrib-modbus and after updating the EPIC firmware, I went ahead and updated this node via the manage palette menu and it updated to 5.26.0. So far, so good…

Then yesterday, I updated EPIC #2 to to 3.5.1-b.85 which includes Node-RED v3.0.2 & Node.js version v14.20.0. Update went fine, so I went into Node-RED to update node-red-contrib-modbus from 5.23.1 to 5.26.0 via the manage palette, but it does not work. Below is the log, where it indicates nodeJS >= 16.0.0 is required (at least I think that’s what it says).

2023-11-28T13:46:26.741Z Install : node-red-contrib-modbus 5.26.0

2023-11-28T13:46:27.082Z npm install --no-audit --no-update-notifier --no-fund --save --save-prefix=~ --production --engine-strict node-red-contrib-modbus@5.26.0
2023-11-28T13:46:49.271Z [err] npm
2023-11-28T13:46:49.272Z [err]  WARN deprecated vm2@3.9.19: The library contains critical security issues and should not be used for production! The maintenance of the project has been discontinued. Consider migrating your code to isolated-vm.
2023-11-28T13:46:55.532Z [err] npm
2023-11-28T13:46:55.533Z [err]  
2023-11-28T13:46:55.534Z [err] ERR!
2023-11-28T13:46:55.534Z [err]  
2023-11-28T13:46:55.535Z [err] code
2023-11-28T13:46:55.536Z [err]  ENOTSUP
2023-11-28T13:46:55.620Z [err] npm
2023-11-28T13:46:55.620Z [err]  ERR! notsup Unsupported engine for serialport@12.0.0: wanted: {"node":">=16.0.0"} (current: {"node":"14.20.0","npm":"6.14.17"})
2023-11-28T13:46:55.620Z [err] npm 
2023-11-28T13:46:55.621Z [err] ERR! notsup Not compatible with your version of node/npm: serialport@12.0.0
2023-11-28T13:46:55.621Z [err] npm 
2023-11-28T13:46:55.621Z [err] ERR! notsup Not compatible with your version of node/npm: serialport@12.0.0
2023-11-28T13:46:55.621Z [err] npm
2023-11-28T13:46:55.621Z [err]  ERR! notsup Required: {"node":">=16.0.0"}
2023-11-28T13:46:55.621Z [err] npm
2023-11-28T13:46:55.622Z [err]  ERR! notsup Actual:   {"npm":"6.14.17","node":"14.20.0"}
2023-11-28T13:46:55.658Z [err] 
2023-11-28T13:46:55.659Z [err] npm ERR! A complete log of this run can be found in:
2023-11-28T13:46:55.659Z [err] npm ERR!     /home/dev/.npm/_logs/2023-11-28T13_46_55_640Z-debug.log
2023-11-28T13:46:55.713Z rc=1

I next did this:


…but that also did not work and gave me a log of errors, the most relevant of which seems to be:

[err]  WARN install No prebuilt binaries found (target=14.20.0 runtime=node arch=arm libc= platform=linux)

What should I do to get over this hump? It seems installing Node.js v16 would fix everything, but strangely last week on EPIC #1, we were able to update node-red-contrib-modbus to 5.26.0.

Thanks in advance!

Was there a specific feature you were after in the Modbus node or did you just feel the need to update a working system?

If there is no ‘required’ feature, I’d go back a version or so…

Rebuilding is not the right thing to do here as you found.

Also we are working on getting to nodejs v 16 (but probably not since - sorry cant find the link with details - nodejs had some issues and had to ‘dump’ an entire release in there somewhere - so we are planing on jumping past 16 I seem to recall), but its going to be some time out.

Anyway, point is, updating nodejs is not going to be an option, so just use the groov Manage install specific version of a node tool to get back to where you need to be.

Thanks Ben. v5.23.0 of node-red-contrib-modbus is now working (it was not earlier, and rather than troubleshoot, I went straight to the upgrade button on the palette manager). It’s a fairly complex flow that scrapes data from several different slave ID’s, passes over any that are off, etc.

I think we should be good now.

@grant1 I think it because the “serialport” updated to 12.0.0, and node-red-contrib-modbus will install this module also. That’s why few weeks before the EPIC can install 5.26.0, but not now. @Beno Is there any way to solve this ? We got the same issues, the EPIC which run at before is fine with 5.26.0, but not the new EPIC.

Hi Beno,
We use the groov Manage to install node-red-contrib-modbus 5.23.0, but the error log as below :
npm ERR! notsup Not compatible with your version of node/npm: serialport@12.0.0
npm ERR! notsup Not compatible with your version of node/npm: serialport@12.0.0
npm ERR! notsup Required: {“node”:“>=16.0.0”}
npm ERR! notsup Actual: {“npm”:“6.14.17”,“node”:“14.20.0”}

What is the reason that @grant1 can installed 5.23.0 in his EPIC but not mine ?
Thanks for your help.

This has turned into a bit of a rabbit hole.
Just know I have spent a few hours on it already today, @torchard and I are now working on it and will report back once we have some clarity.

3 Likes

Hi Beno,
Do you have any updated information ? Thanks.

Soon as I have an update, I will post it.
Still working on it.

1 Like

Oddly enough, I successfully installed v5.0. In this case, I entered just ‘5’ as the version -and it took. My palette says the version is 5.23 and this was on an M2 RIO with firmware 3.5.0

1 Like

@abrooks Thanks for your solution. It’s also workable on my EPIC ! I just put “5” in the block, then I got 5.27.2 without problem.

1 Like

Again, sorry for the delay on this one.
Last week we had our schedualed factory training class here at Opto, both Terry and I teach a few classes and it takes some time away from our desks to do that.

In short, whats happening is that the node-red-contrib-modbus node is made up of other nodes. (42 in total). Some of those nodes have a specific version of nodejs they need. In other words, the software authors of those nodes have updated those dependencies and it is higher than the nodejs version installed on EPIC / RIO.
In some cases, some of those nodes have not changed, but the nodes they depend on have changed.

I have been slowly working my way through the combination of all 42 nodes looking for the highest low version I could install with the nodejs v14 that we are using.
As you can imagine, it was taking some time and I needed to reinstall the EPIC firmware here and there and retrace my steps to ensure the version trail was ‘clean’ and working up to the point where it broke.

Thanks so much for the community stepping up in this issue.
I cant understand how simply putting the version ‘5’ to install is getting around all the versions, but it did.
I watched the live install log carefully and it was amazing to see the versions fall into place as per the notes I had.

I will be sending this ‘one weird trick’ to our support group and lead engineers.

In short, here is what was discovered:

To install the modbus nodes;

At the end, you should see the 42 nodes installed:

image

Don’t forget to restart Node-RED;

3 Likes

Thanks @Beno, happy to help out. Without getting deep into the weeds on this, the resolution has to do with the fact that NodeRed has the ability to resolve dependent issues within a Node as long as the version is compatible specifically within the particular Node.js revision. In this case, v5 spans versions 2 and 3, as well as multiple Node.js revisions as well. I would assume the only reason that this actually worked was because the Node.js 14.2…16+ were fundamentally compatible, at least with regard to this modbus package.

TLDR: Awesome it worked, I wouldn’t expect it to every time. :slight_smile: