Node-Red’s serialport module is outdated. How do you update it?

#1

I have a Raspberry Pi 3 running Home Automation software called OpenHAB. It comes with its own installation script for Node-Red. Many months ago, I used it to install Node-Red and it's been working flawlessly with the flows I've created.

During the intervening months, several apt-get update/upgrades were performed. I'll be completely frank and admit I was happy to live in ignorance of Node-Red's operation; the flows work and that's all that mattered.

Curiosity got the better of me and I recently used node-red-log to examine Node-Red's log and discovered a warning message upon startup. Apparently, the serialport module is version 48 and the version of node.js that's running requires version 57.

30 Sep 22:13:41 - [info] Node-RED version: v0.18.4
30 Sep 22:13:41 - [info] Node.js  version: v8.11.1
30 Sep 22:13:41 - [info] Linux 4.14.62-v7+ arm LE
30 Sep 22:13:41 - [info] Palette editor disabled : npm command not found
30 Sep 22:13:41 - [info] Loading palette nodes
30 Sep 22:13:50 - [info] Dashboard version 2.9.0 started at /ui
30 Sep 22:13:52 - [warn] ------------------------------------------------------
30 Sep 22:13:52 - [warn] [node-red-node-serialport/serialport] Error: The module '/root/.node-red/node_modules/serialport/build/Release/serialport.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 48. This version of Node.js requires
NODE_MODULE_VERSION 57. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
30 Sep 22:13:52 - [warn] ------------------------------------------------------

I googled the warning message and found many solutions but none that seemed to refer to the serialport module (the examples often referred to something called "electron"). I hesitate to blindly apply the solutions because I don't know if they are applicable and I don't fully understand how to use "npm rebuild" or "npm install".

Can someone explain how to update the serialport module (for an RPi)?

FYI
On a somewhat related note, "Manage Palette" was missing from Node-Red's main menu. I discovered from this forum (the old Google Groups version) that it can happen when "npm" is missing. I installed npm and now Manage Palette is visible in the menu. That's about the limit of my involvement with npm so far!

0 Likes

#2

Slightly depends on your installation. For a default installation, you will need to dig around to find the node-red-node-serialport/serialport folder that is likely to be in or near the location where the Node-RED module is globally installed. Unfortunately, I can't give you details as I don't install Node-RED that way.

When you've found the folder, you can indeed use one of the commands given, in that folder, which should rebuild the module.

You might find it easier to reinstall Node-RED itself however which should, I think also fix the issue.

If installed the normal way, npm -g install node-red --unsafe-perm I think is the command. You won't lose anything doing this. Though you should always backup your userDir folder anyway before hand.

0 Likes

#3

Given you say you used an OpenHAB script to install it I would suggest going to the OpenHAB site to ask how they suggest you update it.

The last thing you want to do is to upgrade it yourself to then find it breaks when you do an OpenHAB update.

0 Likes

#4

Thanks for your reply. I see that all modules are installed here:

/root/.node-red/node_modules

The contents of /root/.node-red/node_modules/serialport look like this:

drwxr-xr-x   6 openhabian openhabian  4096 Mar  9  2018 .
drwxr-xr-x 312 root       root       12288 Apr 24 08:13 ..
drwxr-xr-x   2 openhabian openhabian  4096 Mar  9  2018 bin
-rw-r--r--   1 openhabian openhabian  1195 Feb  5  2018 binding.gyp
drwxr-xr-x   3 root       root        4096 Mar  9  2018 build
-rw-r--r--   1 openhabian openhabian 27244 Feb 27  2018 CHANGELOG.md
-rw-r--r--   1 openhabian openhabian    32 Aug  6  2017 codecov.yml
-rw-r--r--   1 openhabian openhabian   100 Dec  9  2017 .doclets.yml
-rw-r--r--   1 openhabian openhabian   613 Oct 31  2017 .jsdoc.json
drwxr-xr-x   4 openhabian openhabian  4096 Mar  9  2018 lib
-rw-r--r--   1 openhabian openhabian  1105 Jun 20  2017 LICENSE
-rw-r--r--   1 openhabian openhabian  4746 Mar  9  2018 package.json
-rw-r--r--   1 openhabian openhabian 22417 Feb 27  2018 README.md
drwxr-xr-x   2 openhabian openhabian  4096 Mar  9  2018 src
-rw-r--r--   1 openhabian openhabian   244 Jul  8  2017 test.js

You said there's a command in there that'll rebuild the module but I don't see anything executable. I also checked the build folder and it has this:

drwxr-xr-x 3 root       root        4096 Mar  9  2018 .
drwxr-xr-x 6 openhabian openhabian  4096 Mar  9  2018 ..
-rw-r--r-- 1 root       root         118 Mar  9  2018 binding.Makefile
-rw-r--r-- 1 root       root        4344 Mar  9  2018 config.gypi
-rw-r--r-- 1 root       root       12765 Mar  9  2018 Makefile
drwxr-xr-x 4 root       root        4096 Mar  9  2018 Release
-rw-r--r-- 1 root       root        3545 Mar  9  2018 serialport.target.mk

Still nothing that I recognize as a command. Any other ideas to point me in the right direction?

PS
Obviously I have no idea how the underpinnings of Node-Red (node.js etc) are structured so I'm clearly out of my depth here. I didn't realize there might be considerable variation from one installation to another.

0 Likes

#5

Hi, you may wish to do a little reading on how NodeJS works. Node-RED is built using NodeJS. NodeJS comes with npm which is used to do module (library) maintenance such as installs and updates.

0 Likes

#6

I did and received one reply that I should backup the RPi and apply the solutions I found elsewhere. In other words, no one there had a specific solution.

FWIW, OpenHAB and Node-Red exist on the same RPi but that's the full extent of their overlap. Besides installing Node-Red, OpenHAB's installation script adds a few nodes to the palette including node-red-contrib-bigtimer and node-red-contrib-openhab2.

I suppose I could uninstall and reinstall Node-Red but I was hoping there was a more surgical solution! :slight_smile:

0 Likes

#7

I expected someone to say that. :slight_smile:

My understanding is that npm serves as the package manager for node.js. I was hoping someone could share the correct incantation to make it rebuild the serialport module.

If not that then can you recommend a good tutorial explaining node.js?

0 Likes

#8

Well, I gave the easiest way. The second easiest way is to run npm install in the serialport folder. But I'd do an install of Node-RED, that's easiest - takes a little longer but makes sure that you don't have other issues lurking.

0 Likes

#9

Make sure you have the latest version of npm before doing anything ! sudo npm i -g npm
will get the latest.

0 Likes

#10

Cant you just to to the Manage Palette menu option in Node-red UI and update it from there?

0 Likes

#11

@TotallyInformation
Thank you for your help! When I have more time I will definitely experiment with a full re-installation to better familiarize myself with the process.

@dceejay
Thanks! I installed it recently but I'll make sure it's the latest before moving ahead.

@jmorris644
Not having had the opportunity to explore Manage Palette (because npm wasn't present until recently) I didn't realize it offered the ability to update individual modules. Thank you for that tip! I had a look and it indeed offers the ability to upgrade serialport to 0.68 (and a few other modules like BigTimer).

I will definitely try this technique but first I'll backup my SD card just in case something goes awry. I'll report back with my results.

0 Likes