Raspberry Pi 3: Node.js Hello world

In this tutorial we will check how to get started using Node.js on the Rasperry pi. We will develop a very simple “hello world” application. This tutorial was tested on a Raspberry Pi 3 model B+.

Introduction

In this tutorial we will check how to get started using Node.js on the Rasperry Pi 3. We will develop a very simple “hello world” application.

This tutorial was tested on a Raspberry Pi 3 model B+, running version 4.9 of Raspbian, installed using NOOBS.

The Node.js version used was 12.2.0. This version is more recent than the one that originally comes installed with Raspbian. Nonetheless, this tutorial should also work for older versions. If you want to update your Node.js version, please follow this guide.

The procedure

The first thing we will do is opening a command line. Once you do it, simply type the following command and press Enter:

node

This should open the Node.js interpreter, where we can send commands. Figure 1 illustrates the expected result after sending the previous command.

Running the Node.js interpreter on a RPI3 command line.
Figure 1 – The Node.js interpreter.

After this, for printing a “hello world” message, simply write the following command and hit Enter:

console.log("Hello world")

You should get a result similar to figure 2. As can be sen, the “Hello World” message gets printed to the console, as expected.

Printing a "Hello World" message on the Node.js interpreter.
Figure 2 – Printing a “Hello World” message with Node.js.

Leave a Reply