Install Node.js and Npm on Raspberry Pi

Raspberry Pi fan.

Intro: Install Node.js and Npm on Raspberry Pi

You can build many apps using node.js and npm on your raspberry pi and it's very easy to interact with GPIO or other components connected to your raspberry pi. So if you are like me and like to do it on node.js here a few simple steps to install node and npm.

Step 1: Detect What Version of Node.js You Need

The processor on Raspberry Pi is ARM, but depends on the model there can be ARMv6, ARMv7 or ARMv8. This 3 versions of ARM is supported by Node.js.

So first of all type this in your terminal on raspberry pi to detect the version that you need:

uname -m

If the response starts with armv6 than that's the version that you will need. For example for raspberry pi zero W you will need ARMv6

Step 2: Download Node.JS Linux Binaries for ARM

Go to node.js download page and check right click on the version of ARM that you need and choose Copy Link address.

After that in the terminal using wget download the tar.gz file for that version. Just type wget, paste the link copied before and make sure the extension is .tar.gz. If it's something else change it to this and it should be ok. For example I will need ARMv6 and I will type this in my terminal:

wget https://nodejs.org/dist/v8.9.0/node-v8.9.0-linux-armv6l.tar.gz

Step 3: Extract the Archive

Using tar that is already installed with the system on your raspberry pi just type this (make sure you change the filename with the file that you have)

tar -xzf node-v8.9.0-linux-armv6l.tar.gz

Step 4: Copy Node to /usr/local

cd node-v6.11.1-linux-armv6l/

sudo cp -R * /usr/local/

Step 5: Check If Everything Is Installed Ok

Check if node and npm are installed correctly. This lines should print the version of node and npm installed.

node -v

npm -v

Now you have node.js installed on your Raspberry Pi and working so you can build something using node

Share

    Recommendations

    • Optics Contest

      Optics Contest
    • Audio Contest 2018

      Audio Contest 2018
    • Electronics Tips & Tricks Challenge

      Electronics Tips & Tricks Challenge

    5 Discussions

    0
    None
    nurf38

    3 months ago

    what if my extension is tar.xz.1. Do i have to change to other extension?

    1 reply
    0
    None
    ErickA70nurf38

    Reply 2 months ago

    Yo tuve buen resultado :

    Usando unxz (ya estaba instalado) --> unxz node-v8.11.3-linux-armv7l.tar.xz

    Luego descomprimí el tar con --> tar -xvf node-v8.11.3-linux-armv7l.tar

    Saludos
    Erick

    0
    None
    JihyeongL

    Question 3 months ago on Step 5

    I've followed this except version of node since the latest version of it is 8.11.3 and my architecture is ARMv7. After copying things to /usr/loacl, I checked node -v. It worked. But when I typed npm -v, the output was bash: /usr/bin/npm: there's no such file or directory. What should I do to fix this? Please help.

    1 more answer
    0
    None
    JihyeongLJihyeongL

    Answer 3 months ago

    solved. npm was in /usr/local/bin so I made link to /usr/bin.

    0
    None
    DIY Hacks and How Tos

    11 months ago

    Nice. Raspberry PI tutorial. You should enter this into the Raspberry PI contest that is currently running.