If you try to check the version of node.js in either WSL/Ubuntu/Raspberry Pi, you normally found the version outdated even though you have run all the updates. E.g. in WSL Ubuntu 18.04, after ran all the updates, it is still version v8.10.0.

  sudo apt-get update  sudo apt-get upgrade  node -v  

For this, you can consider removing the system existing and update it manually. If you want to uninstall, run the command below.

  sudo apt-get remove nodejs npm node-semver  

Then go to nodejs.org to download the update > https://nodejs.org/en/download/.
Beware of the version you need to download either is WSL/Ubuntu x64 or Raspberry PI ARMv7 (32-bit) or ARMv8 (64-bit). You can check your version using the command below.

  uname -a  # WSL Ubuntu will be something like below  # Linux ComputerName 5.4.72-microsoft-standard-WSL2 #1 SMP Wed Oct 28 23:40:43 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux  # Raspberry Pi ARMv7  # Linux raspberrypi 5.10.17-v7l+ #1421 SMP Thu May 27 14:00:13 BST 2021 armv7l GNU/Linux  

Then, run the command below to install manually.

  # Replace the URL copy from above for correct installer and newer version  wget https://nodejs.org/dist/v14.17.3/node-v14.17.3-linux-x64.tar.xz  sudo mv node-v14.17.3-linux-x64.tar.xz /opt  cd /opt  sudo tar -xf node-v14.17.3-linux-x64.tar.xz  sudo mv node-v14.17.3-linux-x64 nodejs  sudo rm node-v14.17.3-linux-x64.tar.xz  sudo ln -s /opt/nodejs/bin/node /usr/bin/node  sudo ln -s /opt/nodejs/bin/npm /usr/bin/npm  

Lastly, run the node -v, you will get v14.17.3 and npm -v 6.14.13.


This free site is ad-supported. Learn more