Node-RED v3.x no longer supports Nodejs 16
You can force an install of node 18 or 20 by adding --node18 or --node20 to the end of the command line above.
However doing so may break some nodes that may need re-installing manually.
Generally it is recommended to update all nodes to their latest versions before upgrading.
If you wish to stay on nodejs 16 you can update to the latest Node-RED 1.x or 2.x version by adding
--nodered-version="1.3.7" or --nodered-version="2.2.2" to that install command. If in doubt this is the safer option.
Please backup your installation and flows before upgrading.
Note: not all embedded hardware can be updated via this method - please check before proceeding.
Exiting now.
Instead using sudo npm install -g --unsafe-perm node-red@3.1.9 works fine with node 16, even with node 17 that I'm currently running, but I am not so happy with how it is installed, I'm using PM2 to start Node-RED. I guess the whole laptop should be re-installed but there are so many things there, time can be spent on other things, everything is anyway working. Is just a frustration why I can't upgrade...
After making a backup and testing that, I used these instructions as the basis, but added commands to upgrade libraries. I was fully aware that this could result in disabling the system. My next OS upgrade will be to a completely new unit with fresh installs of all applications.
Note that I needed to include NodeJS 20 for other reasons and getting to this version was the issue with the older OS.
And that did not work either since node 18 is not supported by Debian v 9. On top of that the script now destroyed the working versions. So now just redo things, using node 17, to make it work again EDIT: with the .bash_history this is done in seconds, no problems
This can take 20-30 minutes on the slower Pi versions - please wait.
Stop Node-RED ✔
Remove old version of Node-RED ✔
Remove old version of Node.js ✔
dpkg-query: package 'nodejs' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
Install Node ✘ Bad install: Node.js missing Npm missing - Exit
Npm rebuild existing nodes
Install extra Pi nodes
Add shortcut commands
Update systemd script
Any errors will be logged to /var/log/nodered-install.log
The nodered-install.log
Already have nodejs
OLD nodejs 17 :
NEW nodejs 18 :
Installing nodejs 18 over 17 .
***************************************
Started : Mon 20 Jan 15:53:03 CET 2025
Running for user pi at /home/pi
Found global nodes: :
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package nodered
Installing nodejs 18
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Reading package lists...
Building dependency tree...
Reading state information...
Package 'nodejs-legacy' is not installed, so not removed
Package 'nodejs' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
dpkg: warning: ignoring request to remove nodejs which isn't installed
dpkg: warning: ignoring request to remove node which isn't installed
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Reading package lists...
Building dependency tree...
Reading state information...
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Grab the LTS bundle
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Reading package lists...
Building dependency tree...
Reading state information...
gnupg is already the newest version (2.1.18-8~deb9u4).
curl is already the newest version (7.52.1-5+deb9u16).
ca-certificates is already the newest version (20200601~deb9u2).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
gpg: WARNING: unsafe ownership on homedir '/home/pi/.gnupg'
Ign:1 http://archive.debian.org/debian stretch InRelease
Hit:2 http://archive.debian.org/debian stretch Release
Hit:4 https://deb.nodesource.com/node_18.x nodistro InRelease
Reading package lists...
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Reading package lists...
Building dependency tree...
Reading state information...
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
nodejs : Depends: libc6 (>= 2.28) but 2.24-11+deb9u4 is to be installed
E: Unable to correct problems, you have held broken packages.
Versions: node:missing npm:missing
Yep, I anyway decided now to try to upgrade Debian from 9 to 10 according to this guide. It is written for a typical AWS EC2 setup but I think it looks ok to use, just need to check those sources.list files in /etc/apt and /etc/apt/init.d
Work is still in ongoing so I can't tell the final result yet. I feel if I do not upgrade at some time, the risk is that I get left too far behind
So finally my last computer, the Lenovo laptop, is now also updated/upgraded
From Debian 9 to 10 followiing the guide I refered to above. It worked out fine but took, as expected, some time, hours. Only had some small issues afterwards, non Node-RED related though
Next I went on with upgrading Node and Node-RED. The attempt with the script failed so I took the "Running Node-RED locally" path
First step, this was a bit exciting, upgrading Node, would that work now? I found earlier this approach worked good:
sudo -i
curl -L https://raw.githubusercontent.com/tj/n/master/bin/n -o n
bash n 20
exit
Now verifying showed I was at v20.18.0!!
Moving on to install latest Node-RED:
sudo npm install -g --unsafe-perm node-red@4.0.8
Since I already had PM2 configured I just rebooted, voilà c'est tout, I am now running Node-RED 4.0.8
I think I did try the script but...I wil re-do now
I don't think I have n installed
pi@WalterLenovo:~$ n
-bash: n: command not found
It's when I run as root I can run a bash script that happens to have the name n
pi@WalterLenovo:~$ sudo -i
[sudo] password for pi:
root@WalterLenovo:~# n
-bash: n: command not found
root@WalterLenovo:~# dir
Desktop get-pip.py opencv opencv_contrib.zip Public
Documents Music opencv-4.0.1 opencv.zip Templates
Downloads n opencv_contrib Pictures Videos
So now trying the script as suggested, as my normal user 'pi'. Node and npm are installed
And this time it worked!!! Must have made some mistake before....now just have to remove the PM2 thing and just let systemd handle it
Stop Node-RED ✔
Remove old version of Node-RED ✔
Remove old version of Node.js ✔
Install Node 20.18.1-1nodesource1 ✔ v20.18.1 Npm 10.8.2
Clean npm cache ✔
Install Node-RED core ✔ 4.0.8
Move global nodes to local -
Npm rebuild existing nodes ✔
Install extra Pi nodes -
Add shortcut commands ✔
Update systemd script ✔