How To – Update Nodejs & npm on a Raspberry Pi
In this tutorial, we see how to update Nodejs & node package manager (npm) on our Raspberry Pi.
To start, open the terminal on your Raspberry Pi. First we will get the latest system’s package list onto the Raspberry Pi using the following command:
sudo apt update
the we will install the latest packages available to the Raspberry Pi using following command:
sudo apt full-upgrade
Next, check the version of Nodejs and npm by typing the following command:
You can see i have see the version no listed for each node and npm, we can update it to the current version using below command. Note: To obtain the newest versions of both Nodejs and npm, you need to first remove and then reinstall their packages, so we get the latest version.
sudo apt remove nodejs
To remove Nodejs, you will be prompted to validate your request so make sure to proceed with a command. Type in Y (Yes) in the command-line to continue to remove Nodejs. Once completely removed you be back at the prompt.
Next use the following command to install the latest version of nodejs
sudo apt install nodejs
Once successfully installed you be see the pi prompt. We can check the version no using the node -v and npm -v.
Excellent ! we have successfully installed the latest Nodejs and npm versions to our Raspberry Pi