Prompted by this and trying to replicate locally I have found that there is a path for us to not actually perform the npm upgrade. Fix in progress.
And what does this testing give?
You can see that it was not run from .node-red
You got the result
Whereas it should be
/home/pi/.node-red
└── (empty)
If you look at the package.json for that calendar node it specifies the dependency
"node-red": "~1.0.3"
which says that it requires a version of node-red >= 1.0.3 but <1.1.0 so it has installed an extra version of node red (1.0.6) just for itself. Why it has that dependency I don't know and I don't know what effect having node-red installed like this will have. I think you should raise an issue on the node's github page. Is that node working ok for you?
So I arranged it, but now I’ll probably give it up.
And yet, to the question about version Node.js, can you use a script to upgrade to version 12 or higher?
I tried to install Node.js separately, but then the update script stopped working.
So how did you (re)install node.js ? If you want to re-use the script again then
if you used apt to install nodejs - then use sudo apt purge nodejs
to uninstall it
otherwise manually you can sudo rm -rf /usr/bin/node /usr/bin/npm /etc/apt/sources.list.d/nodesource.list
then sudo apt update
- then re-run the script.
Thanks for the feedback, Colin. Anyway, as you can see there was a bug in the script, Dave wrote last night with a fix – so everything now works – confirmed on 2 separate RPis. The updated script has gone online this morning (I've not check, taking Dave's word for it.
I can't be the only one – this will no doubt help others who are struggling with the update who won't think to write in. I can feel my writing arm working.
Regards
Pete
Thank you, Mister! Finally, I have a clear and specific path to update.
sudo apt purge nodejs
curl -sL https://deb.nodesource.com/setup_12.x | sudo bash -
sudo apt-get install -y nodejs
node --version
sudo apt update
bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)
You should have done the update after the curl -sl ...
otherwise it would not have seen the nodesource setup. But that was not necessary anyway as the bash script would have done it for you.
Without knowing the nuances, it is difficult to do it right. It would be great if a section on updating Node.js appeared in the instructions for Raspberry Pi. Until today, I thought that the script itself updates the version Node.js to the current one, but this turned out to be wrong.
This is the danger of relying on someone else's script without understanding the detail. It is great (and Dave's script really is great) until something trips it up. That's one of the reasons I personally prefer not to use such scripts. Generally I don't even bother to use my own scripts! Instead I tend to keep a OneNote note with all of the instructions in it to rebuild a platform (Pi or now laptop for me) from scratch. That is because things often do slightly change between the relatively rare occasions you need to do such things but having the instructions means that it is usually pretty trivial to adapt them on the fly.
So I will always do an apt upgrade first, then install basic software including node.js, then add necessary tools like the build essentials, then install node-red (which I do locally rather than globally because it means it is always exactly where I put it and I don't have to try and remember where the global install puts it - different on every platform. Also means that I can easily back-up or move or copy the whole shooting match in one go). Then add my NR configuration, settings, flows, etc.
For upgrades, once youve added node.js, all you need to remember with my setup is:
sudo apt update && sudo apt upgrade
cd ~/nrlive # or wherever you put Node-RED
npm outdated # check if NR needs an update.
# npm install node-red --unsafe-perm # if NR needs an update, I have this in an npm script so just need `npm run update`
cd data # where I keep the runtime stuff, my userDir
npm outdated
npm update # if needed
Since my terminal always opens by default to ~/nrlive
, that is one less command
All the commands are on npm scripts defined in package.json anyway so it is all very easy.
Check out the alternate install on my GitHub for more detail.
As I only do this probably once a month or less, it really isn't any trouble and soon becomes second nature. If anything goes awry, it is obvious where and so usually obvious how to fix.
Anyway, for what it is worth, that's my way of doing it. Maybe I'm just too OCD
This is a good experience, something like what I do, but in my experience, the majority of Node-Red users are not system administrators, but application-level users. If it weren't for Raspberry, I didn't need Linux at all. It is not convenient in everyday work, morally outdated and can only be liked by enthusiasts. Windows has no problems with updating. Therefore, it is better to have clear instructions for everyone, and not everyone's personal experience.
dceejay told you exactly what to do in post #46, but you did not follow his advice.
Which was to purge nodejs then run the re-script.
Why did you decide that? I did as he wrote, deleted the old version, updated Node.js and ran the script, thanks to him for that.
Will the script update Node.js itself if I do it first as in post 46?
Checked it doesn't work.
I did as I described earlier. At the same time, I switched to version 14.
We cannot guarantee that we are the ones who installed node.js. if the user has other apps using node, if we upgrade node with asking/checking we will break their other apps.
You can ask a question at the beginning of the update. Whoever needs it will update, whoever doesn’t need it will miss.
You have provided the vital clue. You are for some reason using N to manage nodejs as it shows in the screenshot you posted, therefore the script does not attempt to override that.
Once upon a time, I was looking for a way to update Node.js to Raspberry. I used the most popular Google answer at the time [https://coderoad.ru/Raspberry-Pi](https://coderoad.ru/42741243/Как-установить-новейшую-версию-node-js-на-Raspberry-Pi). There the installation method was indicated -curl -L https://git.io/n-install | bash
. Now I would rather get rid of this manager N. Everything has to be learned experimentally.
Deleted manager Node.js, then according to the description of the 46th post. And what we see, again Node.js version 10. But the point was to update to 12 or 14 ...
Without wishing to get into a platform war, I think that I need to provide some balance here for anyone else who stumbles on this discussion.
The classification of Linux as "morally outdated" is very odd. It is the most popular server OS by far. Even the majority of Microsoft's own Azure global cloud IaaS services are running Linux. And therefore "only be liked by enthusiasts" cannot be correct either. Indeed, the second most common desktop OS (MacOS) is based on BSD which is a close relation of Linux - though of course the guts of that is well hidden from most users.
You can, if you wish, choose to run Windows Core on a Raspberry Pi thanks to the work done by Microsoft and while I've not tried it myself, I suspect that you could run Node-RED on that OS if you wished to.
As an IT pro with expertise in Windows since its inception, I can assure you that this is also not correct. All of the desktop and server OS's have update issues quite regularly.
Further, the management of Node.js on Windows is generally rather harder than on Linux. You have to do a new install for each update unless you are using one of the only partially supported 3rd-party updaters such as chocolaty. On Linux, once you have added the repo to apt, updates happen along with everything else and can easily be automated if you like.
Node-RED is a server platform. So some knowledge of how servers/services run and work is going to beneficial for anyone even if you class yourself as an "end user". Node-RED is not alone in this respect, other server platforms such as Jupyter have the same issues. But Node-RED, using as it does the npm infrastructure, is a lot easier to manage (I find) than something like Anaconda is for managing Python/Jupyter. But either way, a level of knowledge over and above that of someone who mainly uses a browser is expected.
My outline process follows the "standard" way of managing node.js applications which is why I use it and why I mentioned it. Once learned, you can use the same process for any node.js application or module that properly uses npm.
The work that Dave, Nick and others have put into Dave's script give beginners an excellent leg-up in order to get started quickly. But a script will never cover every eventuality. Knowing what to do then is beneficial to all users of Node-RED I believe.
I didn’t talk about the server. There are sysadmins that are their job and the command line is a lifelong love. I was talking about ordinary users. And here the higher the level of abstraction, the more comfortable the work and the faster the result, albeit at the expense of additional resources. This is what I like about Node-Red, although you can do everything in JS. In the future, with the increase in the power of minicomputers, I will give up Linux.