0

$USD

$USD
TUTORIALS Raspberry Pi

Raspberry Pi 3 Tutorial: Node.js Hello world

DFRobot Jun 09 2019 816

In this Rasperry pi 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 raspberry 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.

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.

Figure 2 – Printing a “Hello World” message with Node.js.