Wanting to update node on Ubuntu. Docs confusing

(Yes, I know I have asked before. And I am again asking.)

It is a double edge sword for me that if I write something down as being the way to do it chances are it will be updated and/or changed.

I am running NR on Ubuntu 18.04 LTS and my node version is old.
(Well, I am still running pre 1 Node Red)

Anyway, following the rabbit hole of docs I found this:
How to update NODE

Yes, I know it says node.js and I am talking node.

Anyway, towards the bottom of the screen:

Upgrading Node.js

If you change the version of Node.js you are using, you may need to rebuild Node-RED’s dependencies as well as any nodes you have installed. This is because some of them contain binary components that must be rebuilt to be compatible with the new Node.js version.

This can be done using the command npm rebuild - but it must be run in the right directory.

There are two places it should be run:

  1. In your Node-RED user directory, ~/.node-red - this is where any additional nodes you have installed are.
  2. In the directory you installed Node-RED

If you installed Node-RED as a global module and are not sure where that put it, you can use the command npm list -g --depth 0 to find where your global modules are installed.

Fantastic. So I need to be in ~/.node-red

Ran the command, a squillion lines of stuff flew past. ( npm rebuild)

node -v Same as before.

Sorry, but I am still not getting it.

This isn't going to help my credibility, but.....

In those docs:

There are two places it should be run:

COULD be run.

Should implies it has be run twice.

These docs are telling you what you need to do after you have updated node.js. They don't tell you how to update node.js. That will depend on how you installed it originally and what instructions you followed then.

Ok, so if I used the stated "use this script to install NR" I am still not getting what I need to do.

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

Update node(.js) - use google to determine how.
Run the node-red install script.

My understanding is if I run the script (mentioned above) it updates the entire NR system.

I'm running 0.20.8 but my node version is a bit dated.

So I want to update the node part - if possible.

Is it node-red or node (ie node.js or nodejs) that you want to update?
Which version of nodejs do have after running the script?

who/what ever it is that is shown when I do:

node -v

Well, as I asked before, what does it show?
Also what version do you want?

me@me-desktop:~/.node-red$ node -v

That is a supported version of nodejs which I assume is why the script does not update it. If you uninstall that and then run the script again it should install 12.x I think.
Probably you can uninstall it by running this, though it does depend on how it was installed initiall. The rm command may fail if the file is not present, but that doesn't matter.

sudo apt-get remove nodejs
sudo rm /etc/apt/sources.list.d/nodesource.list

After running those then node -v should say command not found, so then run the script again.

I'm an idiot.

Which script?

I am not wanting to update Node-Red yet. When the new version was released I asked about the merits of updating and I was advised against doing it. So for now I won't.

But I would like to keep other things up to date. (If possible.)
I did the two commands and so node -v does give an error.

Just read again the earlier threads and see you don't want to run the bash curl install script, I initially thought you had already done that. To install a specific version of nodejs (I did ask but you didn't tell us which one you want) see

Obviously replace the 6 with the version you want. You might also want to look at


I am very sorry I am not making sense. Believe me, it worse for me than you.

Yes, with you sort of there.

But it says npm rebuild.
No version mentioned.

Looking at the table on the Node.js Tutorial: Ubuntu. Does NR 0.20.5 support version 12.x?
(But again, I am failing to see where to enter the version number when all I can resolve from the page is npm rebuild. Which is to be run in the ~/.node-red directory.)

The first link tells you how to install a specific version, in the black box at the beginning. But if you don't know which version you want to install then that is a completely different question. Why do you want to upgrade nodejs but not node-red? It doesn't make sense.

Well, I am at a loss to answer why I don't want to update NR.

I just remember that when it was released and I asked about updating it, someone posted an advisory against me doing it.
(Not having a go at whom ever that is/was.)

I seem good at messing things up - I am sure you can attest to that.
Maybe it was a precautionary thing. I can't honestly say.

But in a more recent post (the new dashboard and multicolour gagues) I said I only get 5 colours even when I click the 2 colour box.

I posted the versions I have and @hotNipi (I think) said my node version was a bit dated.
So I thought I would at least get that up to date.

Ok, putting the bullet in my mouth and trying:

me@me-desktop:~/.node-red$ $ curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
[sudo] password for me: $: command not found


I pressed ^C when I saw the command not found.

So I am really missing something (else?) also.

The dollar sign is the prompt that is already there, don't put that in. I thought the post you mentioned was saying the the old node-red version was likely to be the problem.
I think you would probably be best just to run the pi install script to get a consistent set of everything. The advice not to upgrade was, I guess, just after the new node-red was released, at which point there were a few teething difficulties. I have upgraded all my systems without a single problem.

1 Like

Thanks for catching the $.
I cut too much from the example screen.

Rolling out the new NR to the RPIs is going to be slow and painful.
That may be for a new day when I have more time to study things better.

For now I would be happy to get it on the NUC (Ubuntu 18.04) to get a feeling for it.

You should hardly notice any difference.

Thanks. (Again)

Maybe tomorrow for both types.

I'm now stuck on another project and building messages.
I really should get my act together with .... (sorry. I'm ranting.)