I removed nodejs then ran the script without the node16 option and got an error and the upgrade aborted. The install log is:
Started : Sat Oct 30 14:48:05 MDT 2021
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...
Package 'nodered' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Versions: node:missing npm:missing
OLD nodejs 0 :
NEW nodejs 16 :
I ran the script again with the --node16 option and everything seemed to go well, but still get the following:
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Reading package lists...
Building dependency tree...
Reading state information...
Package 'nodered' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Using n
installed : v16.13.0 (with npm 8.1.0)
Versions: node:v16.13.0 npm:8.1.0
npm WARN using --force Recommended protections disabled.
Now install Node-RED
added 290 packages in 1m
2.1.3
Now create basic package.json for the user and move any global nodes
Running npm rebuild
rebuilt dependencies successfully
Installing extra nodes: node-red-node-pi-gpio@latest node-red-node-random@latest node-red-node-ping@latest node-red-contrib-play-audio@late$
up to date in 6s
Now add the shortcut and start/stop/log scripts to the menu
Now add systemd script and configure it for pi
ln: failed to create symbolic link '/usr/bin/python': File exists
Now add launcher to top bar, add cpu temp example, make sure ping works
The user `pi' is already a member of `gpio'.
Memory : 1.0G
Started : Sat Oct 30 14:48:42 MDT 2021
Finished: Sat Oct 30 14:51:38 MDT 2021
I think you are saying that you run the install, it upgrades to node16 fine if you use the --node16 flag
But, if you immediately re-run the install script again, instead of it just noticing that you are up-to-date - it fails and tries/reverts you to node10
I think it is sorted now, but waiting for the OP to confirm. The problem was that there were two versions of nodejs installed at the same time. nodejs 10 was installed using apt, but also nodejs 16 was installed via the script. Having uninstalled the apt version then I believe all is well. The dual nodejs situation appeared to confuse the install script.
Actually I have just noticed this. You have installed n which also may give problems with the install script. Perhaps that is how the issue arose in the first place.
Yes node red was working each time I upgraded, however I was trying to ensure that I ended up with the latest node.js and npm. I wasn't sure if the fact that v10.24.0 was still showing up was a problem, and not sure why, after using the script to upgrade to node v16x, the next upgrade without the --nodexx option would fail and revert back to v10x.
I think I'm starting to understand from the replies that there were two nodejs versions installed, I didn't know two versions could exist (it's not only the script that might have been confused ).
You have a typo, try nodejs -v instead of nodejs-v
Thanks Paul
I vaguely recall having installed n. This installation was a few years old before I started upgrading and I started that a year or so ago, and I must have found n on the web as a way of trying to upgrade nodejs and npm so the node red script wouldn't fail. This was before I learned that the --nodexx option was something to add after the last ) in the script.
I still am not sure how to upgrade nodejs and npm on their own (i.e. not using the node red script), the nodejs.org documentation doesn't appear to cover that.
However, my takaway from all this is - don't try to install nodejs or npm on my own, leave it to the node red script.