I can't upgrade nodejs version from 10.24.0 to 14.16.1(LTS) on Raspberry Pi Desktop

Viewed 2190

I installed Raspberry Pi Desktop on an old laptop and then I installed nodejs using 'sudo apt install nodejs'. After that, when I verify the version of node, using 'node -v' or 'nodejs -v' I get 'v10.24.0'. Then I try upgrade the Nodejs version but it doesn't work because whatever way I used to upgrade, the version stays the same.

I try this:

    pi@local-server-raspi:~ $  sudo su -  
    root@local-server-raspi:~ # apt-get remove nodered -y  
    root@local-server-raspi:~ # apt-get remove nodejs nodejs-legacy -y 
    root@local-server-raspi:~ # apt-get remove npm -y

    root@local-server-raspi:~ # curl -sL https://deb.nodesource.com/setup_14.x | sudo bash -

    root@local-server-raspi:~ # apt-get install nodejs -y
    root@local-server-raspi:~ # node -v
    v10.24.0

    root@local-server-raspi:~ # npm -v
    bash: npm: command not found

I also try with nvm but with the same result, when I type 'nodejs -v' I get 'no such file or directory' and when I type 'node -v' I get the same version, 10.24.0.

I appreciate it if any of you have some idea how to upgrade the version of the nodejs to the LTS version, 14.16.1.

2 Answers

I had the same problem while trying to install nodejs to the raspberrypi 4. I needed a newer version to run yarn. There are many tutorials but this instruction video (below) fixed my problem and upgraded the nodejs to 14.16.1. (Thanks Dave!!!) thisdavej.com/upgrading-to-more-recent-versions-of-node-js-on-the-raspberry-pi/

I had the same problem on Raspberry Pi3. I tried all sorts of things and this is what finally worked...

node -v
v10.24.0

# Remove...
sudo apt remove node
sudo apt remove nodejs

# Install...
sudo curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs

# Check
node -v && npm -v
v14.19.3
6.14.17
Related