Guide to Installing Node.js on a Raspberry Pi

Node.js is a open source platform to create network applications using JavaScript. The applications are executed on the server and not as usual on the client in the browser.
Integrated modules, such as the HTTP-module, enable the realisation of web servers. Additional modules can be simply installed using the supplied package manager npm.

Update 04.09.2016: – Added further, alternative guide


Install Node.js – Option #1 (Raspberry Pi B+ and older)

  1. As a first step you need to download the ARM package that is optimised for Node.js.
  2. Node.js can now be installed using
    sudo dpkg -i node_latest_armhf.deb
  3. Node.js and the package manager npm are now installed. You can check the installed version unsing node -v.

Install Node.js – Option #2 (Raspberry Pi 2/3 and newer)

  1. Add the Node.js source to your package list.
    curl -sL | sudo -E bash -
  2. Node.js can now be installed using
    sudo apt-get install -y nodejs

    You can check the installed version unsing nodejs -v.

Test Node.js with a “Hello World” application

  1. Create a JavaScript file using
    sudo nano helloWorld.js

    and add the following code:

    var http = require('http');
    http.createServer(function (request,response) {
     response.writeHead(200, {'Content-Type': 'text/plain'});
     response.end('Hello World!\n');
    console.log('Web Server running at');
  2. Execute the script with:
    node helloWorld.js
  3. Open the browser and go to the address.


    Node.js Hello World

Leave your vote

8 points
Upvote Downvote

Total votes: 1

Upvotes: 1

Upvotes percentage: 100.000000%

Downvotes: 0

Downvotes percentage: 0.000000%

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.