What is the recommended way of upgrading Node on a Raspberry Pi?


I'm running NodeRED on a Raspberry Pi 2 and it works really well. I installed it using the guide here that says to run this script:

bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)

After a while it installed Node v8.x along with NodeRED 0.19.x - This was sometime last year I think.

Today I'm try to use this node which requires Node v10

works with node version 10 but not with node version 8!

So long story short I'd like to upgrade to Node v10 - I tried running the update-nodejs-and-nodered script again and it updates my Pi to NodeRED to v20.5 but my Node is still v8.

Should I try completely removing NodeRED and Node and running the update-nodejs-and-nodered script again? Or is there a better method?

I'm running Raspbian Stretch OS

Stop node red then uninstall node 8.x
sudo apt-get remove nodejs
then remove the node 8.x repository spec
sudo rm /etc/apt/sources.list.d/nodesource.list
Then re-run the script.


Thanks very much, it took a while for the script to do it's thing but it all worked in the end. :slight_smile:

I did see this message when removing nodejs

Removing nodejs (8.12.0-1nodesource1) ... dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator' not empty so not removed

But everything is working OK so I'm not going to go and tinker with the node_modules files.