Node.js is already installed in most Linux systems, including the Raspberry Pi system; however, it’s not an updated version. So, in this article, you will see different ways to update Node.js on the Raspberry Pi system.
Update Node.js on Raspberry Pi
To update Node.js on Raspberry Pi, follow the below-mentioned methods:
Before going straight toward the methods’ description, let’s find out the version of Node.js installed on the system using the following command:
Since the latest version of Node.js is “19.1.0” while on the Raspberry Pi system it’s “12.22.12”. Thus, we should update the version for improved security and enhanced features.
Method 1: Update Node.js on Raspberry Pi Through Node Module
Node module is a Node Package Manager (NPM) part that allows you to install the latest version of Node.js on your Raspberry Pi system. To install this module, follow the below-mentioned command:
After the NPM installation, you can install the latest version of Node.js through the “n” module using the following command:
Wait for the installation to complete and you can see the Node.js version number on the terminal screen. You can confirm the Node.js update process through the following command:
You may close the terminal, reopen it and apply the “node -v” command to confirm the update.
Method 2: Update Node.js on Raspberry Pi Through Node Version Manager
Node Version Manager (NVM) is a tool to update and switch to any Node.js version easily. To download and install this tool on Raspberry Pi, follow the below-given command:
Alternatively, you can also use the “curl” command to install NVM on Raspberry Pi.
Confirm the NVM installation through the following command:
In case the “nvm” command is not found close to the terminal, reopen it and apply the “nvm -v” command again to confirm the installation.
After installing the NVM, use the command below to install the latest Node.js version Raspberry Pi.
You can confirm the Node.js latest version through the following command:
That’s all from this writeup.
Conclusion
Node.js is a tool for running JavaScript code outside the browser. Having the latest version of Node.js adds the latest security features and improves the tasks’ efficiency. You can easily update Node.js on Raspberry Pi through node module (n) and Node Version Manager (NVM). Both methods install the latest version of Node.js and automatically update it with the old version installed on your Raspberry Pi system.