Help upgrading Node

A few days ago I upgraded Node-RED to 2.2.0 with

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

But Node.js was still at 12.22.10, and I want to install a Node that requires Node.js 16, so I tried running the commands on the Node.js homepage:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
nvm install --lts

And now node -v returns 16.13.2, but Node-RED is still running under 12.22.10 even after reboot.
I tried running the above bash <(curl... again but it didn't solve, and I also noticed it said something about how using nvm was not recommended.

What should I do next?

I am running Ubuntu 20.04

Thank you!

Hello ..

you are right .. its not recommended to install Nodejs using nvm
you should try to uninstall it ..
and just let the bash script install the version of Nodejs
by just adding to the end of the command --node16

bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) --node16

2 Likes

Here's what I tried...

nvm use system
//Now using system version of node: v12.22.10 (npm v6.14.16)
nvm uninstall 16.13.2
//Uninstalled node v16.13.2
nvm unload
sudo nano .bashrc

Removed these 3 lines:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm

reboot

bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) --node16

I got the NVM warning again, and after install, I could not use node-red-start. I had to use ./node-red and when I exit, Node-RED shuts down. And it's still using 12.22.10!

So I guess I didn't completely do away with NVM...

If it's too complicated to fix at this point, I could go back to an earlier snapshot...

Ok I removed the ~/.nvm folder, rebooted, then ran the bash <(curl... script again.

Looks like I'm back in business!!

1 Like

With NVM and similar tools, I think that each node version gets its own environment. That means that if you change node versions in nvm, you need to reinstall node-red for that version.

Similar concept to Python virtual environments - except that with Python, you can also get versions of Python from different vendors - massively confusing!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.