However, I find that if I npm remove node-red (leaving nodejs20 installed) and then re-install the same version using of node-red using sudo npm install -g --unsafe-perm node-red
then when I run node-red it just says Illegal Instruction.
If I then remove node-red again run the script again then all is once more working.
In the failing mode I tried running npm rebuild in /usr/lib and in the .node-red directory but that made no difference.
I am guessing that for some reason the wrong architecture of something is being installed, but can't see what the difference is when run via the script. Has anyone any ideas?
I am getting somewhere now. It isn't the install itself that is different. I inserted an exit statement in the script right after the install and then I get the illegal instruction error again. I will have to look carefully at what comes after. I am not installing the pi specific nodes so it isn't that.
I have found it, I should have seen it hours ago. I thought I had looked through this bit of the script, but there I now see
# If armv6 then remove the bcrypt binary to workaround illegal instruction error
if uname -m | grep -q armv6l ; then
$SUDO rm -rf /usr/lib/node_modules/node-red/node_modules/@node-rs | $SUDO tee -a /var/log/nodered-install.log >>/dev/null
fi
Yup, as expected, a C library that requires compilation. Presumably not compatible with whatever C compiler is present on that device. I vaguely seem to remember that it has a JavaScript fallback version?
Ah, OK. I think it should try to build it if a pre-built version doesn't exist. Possibly the make config for armv6 has been removed if it is no longer supported.
Sorry Colin, can't remember whether you said this. But did you try installing the raw library into a dummy npm package? Does it give the same error? I don't have any Pi Zero's to try it on I'm afraid.