How to install Node.JS on Raspberry Pi

The Raspberry Pi is a great Multi Purpose mini Linux based computer you can use for almost anything. It can be used to create fun side projects. The Python 2.7 programming language is usually available by default on Raspbian and two code Editors are usually available i.e. Geany and Thonny, which are great tools to play around with.

This is great, but most developers usually prefer to develop software on their laptops and deploy their code to a server or another device to run it on. In some cases you probably do not want to use Python to develop your application.

In this post we will take a look at installing NodeJS, an open-source, cross-platform JavaScript run-time environment that enables execution of JavaScript code on a server.

Does Raspberry Pi support NodeJS

NodeJS is an ever moving target and there are new releases of the framework every couple of months. One older versions of Raspberry Pi previous versions of NodeJS was supported but they had to be specifiically compiled to support ARM chipsets. I have previously posted about installing older versions of NodeJS on Raspberry Pi.

In this post we will be discussing how to install NodeJS on the Raspberry Pi B+ version 2 and above. There are 2 ways of finding out your version of Raspberry Pi, the first you can read the circuit board and it will be printed next to the Raspberry Pi Logo.

Raspberry Pi 3 B+ Motherboard

The second approach to finding the version, is to use the handy Linux uname command . To do so you can either open a terminal window or connect to Raspberry Pi using SSH and execute the following command.

Shell

If the Pi responds with armv6 you are running a Raspberry Pi based on the older ARMv6 chipset and you should follow the instructions on how to install older versions Node.JS on the older raspberry pi chipset.

If the response if armv6l or anything else then you can continue with these instructions.

Equipment used in this tutorial

Installing Node Version Manager on Raspberry Pi

There are a lot of different versions of Node out there. These tools will help you keep track of what version you are using, and also make it easy to install new versions and switch between them.

When developing software using Node you will invariably need o switch between different versions to debug and test. Node Version Manager (NVM) makes this a completely seamless process.

The process to installing NVM on Raspberry Pi is similar to installing NVM on Ubuntu and the instructions for using it are exactly the same.

To install NVM on your Raspberry Pi simply use the following command in a terminal window

Shell

Once the installation has completed, you will need to refresh your Bash profile to ensure the new commands become available in your current terminal session

Shell

Installing Node versions with NVM on Raspberry Pi

Once NVM has finished installing you can install the node version of your choice on your Raspberry Pi.

In my case I want to install Version 10 on my Pi using

Shell

Once complete you can use node to check your version number

Shell

You can also check which version of npm (Node Package Manager) has been installed using

Shell

Summary

The process to installing Node Version Manager and Node on your Raspberry Pi is not too dissimilar to installing it on any other *nix based systems.

Gary Woodfine

Technical Director at Denizon
Gary is Technical Director at Denizon, an independent software vendor specialising in IoT, Field Service and associated managed services,enabling customers to be efficient, productive, secure and scalable in a way which helps them address and reduce their ecological impact.

Denizon's product line successfully integrate IoT, Artificial Intelligence and Blockchain technology to enable efficient, productive, secure and scalable solutions to help organisations address increasing energy demands, ecological impact and Health & Safety concerns of their staff.

Latest posts by Gary Woodfine (see all)