How to Install NodeJS on a Raspberry Pi? - Raspberry Pi Projects, Tutorials, Learning DIY Electronics - Makergenix



How to Install NodeJS on a Raspberry Pi?

We'll walk you through the simple steps of installing NodeJS on the Raspberry Pi in this tutorial.

How to Install NodeJS on a Raspberry Pi?

NodeJS is an open-source framework for running JavaScript code outside of a web browser. The use of command-line tools and server-side scripting to drive dynamic websites has swiftly gained popularity among developers.

It's a powerful runtime with great throughput thanks to its event-driven architecture. It also makes use of the V8 JavaScript engine, which was originally created for the Chrome web browser.

Installing the NodeJS runtime on your Raspberry Pi is a simple task that only requires a few instructions.

You'll also need to install NPM on your Pi in addition to NodeJS. NPM is NodeJS' default package manager, and it's where you'll install extra modules.

You may install this JavaScript runtime on a headless Pi because it doesn't require a GUI to function.

The newest version of RPi OS Bullseye was used to test this guide on a Raspberry Pi 400.

Installing NodeJS on a Raspberry Pi

This section demonstrates how to install the most recent versions of NodeJS on the Raspberry Pi.

Download the Node.js source code or a pre-built installer for your platform, and start developing today.

Download the Node.js source code or a pre-built installer for your platform, and start developing today.

We'll use the distributions offered by NodeSource to make this procedure as simple as possible. In addition, this group produces Debian builds, which is the foundation for the Raspberry Pi OS.

Furthermore, these NodeJS binaries are compatible with both 32-bit and 64-bit ARM computers, making them ideal for our Raspberry Pi.

1. Before we begin installing NodeJS on our Raspberry Pi, let's make sure our operating system's packages are up to current.

Using the following two commands, we may update the package list and upgrade any existing packages.

sudo apt update sudo apt upgrade

2. Decide if you want the LTS (Long Term Support) release or the most recent version for the following step.

LTS releases are the most stable, and they are supported for at least 30 months after they are released.

The most recent release will include all of the most recent enhancements, although it may be more unstable.

Run the following command to add the repository for the newest version of NodeJS on your Raspberry Pi.

curl -fsSL | sudo -E bash -

Utilize the command below if you wish to use the current LTS release.

curl -fsSL | sudo -E bash -

3. Now that we've added the NodeJS repository to our Raspberry Pi, we can install the runtime.

We just need to install the package because the script we ran in the previous step performed a package update.

sudo apt install nodejs

4. Run the following command to confirm that NodeJS has been successfully installed.

The version number will be retrieved from the runtime environment with this command.

node -v

We received the following version string on our command line because we're using the LTS release of NodeJS (v16 at the time of Publish).

Additional Development Tools to Install

When using NPM to install extra modules, you may run into problems if the module requires compilation to work with native hardware.

Most of these difficulties may be resolved by installing the "build-essential" package. This package offers a number of tools for compiling applications.

This package may be installed on your Raspberry Pi by running the command below on your device.

sudo apt install build-essential

At this point in the tutorial, you should have successfully installed NodeJS on your Pi.

If you have any problems installing the programme, please comment.


Most Viewed Posts

Write For Us


Email *

Message *

All Blogs