What I learned today

What I learned today

Personal blog about programming and all that stuff

25 Aug 2020

The easiest way to install NodeJS on a Raspberry Pi

The installation of NodeJs on a Raspberrry Pi can be accomplished on various ways. This article shows the easiest way to do it.

Install NodeJS on a Raspberrry Pi

Step 1: Installation of nvm

Use the installation script to install the Node Version Manager:

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

Then the profile script must be executed again (or the terminal restarted):

source ~/.bashrc

Check the nvm version:

nvm --version
0.35.3

Step 2: Installation of NodeJS

To install a specific NodeJS version using nvm, use the command:

nvm install <node-version>

To set this version as the default version of NodeJS on the system use the command:

nvm use <node-version>

Check the successful installation of the NodeJS version:

node -v

Upgrade from an earlier version:

nvm install <node-version> —reinstall-packages-from=<old-node-version>

Installing NodeJS this way will also install npm.