What can I do to prevent Node-RED from crashing when trying to access the serial port /dev/ttymxc0 of device NFX8M-D2-N32-010 with it?

Q

What can I do to prevent Node-RED from crashing when trying to access the serial port /dev/ttymxc0 of device NFX8M-D2-N32-010 with it?

A

The problem is caused by the "serialport" binary package (npm based)  installed and used by Node-RED when using Node-RED nodes from the palette such as "node-red-node-serialport" or "node-red-contrib-modbus: The package is corrupt if used on a Docker host that is an ARM64 processor-based ... as the device NFX8M-D2-N32-010 is.

To prevent Node-RED from crashing: the installed binary package needs to be rebuilt in the container after the desired nodes have been installed.

STEP 1: Run the Node-RED container as it is usual with the following command line

Install Node-RED container
docker run -d -p 1880:1880 --device=/dev/ttymxc0:/dev/ttymxc0 --group-add dialout --name=nodered nodered/node-red

STEP 2: Install now all the nodes you would like to use via the Node-RED palette function. E.g. "node-red-node-serialport" or "node-red-contrib-modbus". Do not use them yet!

STEP 3: Use the following command line to rebuild the all the container's libraries and to restart the container. This may take 20-30 seconds for execution.

Start a container shell
docker exec -w /data nodered /bin/sh -c 'npm rebuild --build-from-source' && docker restart nodered

Use the serial port-related nodes as usual from now on.