Install Node.js on Raspberry Pi

node.js on raspberry pi


Install Node.js on Raspberry Pi Using NVM or Direct Binary

This guide covers installing Node.js on a Raspberry Pi, using NVM (Node Version Manager) for most architectures, and direct binary installation for ARMv6 devices.

Overview

  • NVM Method: For standard Raspberry Pi architectures (e.g., aarch64, armv7l)
  • Direct Binary Method: For armv6l (e.g., Raspberry Pi Zero/1)

Check Architecture

uname -m
  • armv6l: Use binary installation.
  • Other architectures: Use NVM.

Method 1: Install Node.js Using NVM (Recommended)

Install NVM

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
source ~/.bashrc  # or source ~/.zshrc if using zsh

Install Node.js 18 with NVM

nvm install 18
nvm use 18
nvm alias default 18

Check Node.js and npm Versions

node -v
npm -v

Method 2: Direct Binary Installation for ARMv6

1. Download Node.js 18 Binary

wget https://unofficial-builds.nodejs.org/download/release/v18.19.0/node-v18.19.0-linux-armv6l.tar.xz

2. Extract and Install

tar -xJf node-v18.19.0-linux-armv6l.tar.xz
sudo mv node-v18.19.0-linux-armv6l /usr/local/node18
echo 'export PATH=/usr/local/node18/bin:$PATH' >> ~/.bashrc
source ~/.bashrc

3. Verify Installation

node -v
npm -v

Conclusion

You have successfully installed Node.js 18 on your Raspberry Pi using either NVM or a direct binary method for ARMv6 devices. Enjoy building and running Node.js applications on your Raspberry Pi!

Back to blog