Recently I got a Raspberry Pi B+ and I couldn’t wait to start playing with it. My first project was a server application, which runs on NodeJS and uses MongoDB for storing data. This post will guide you how to setup a Pi with Node and Mongo as in my case, this was not that straightforward.

Before you Begin

Note that just doing “apt-get install nodejs” will not work on the Raspberry as the package is not compiled for ARM. Even if the package installs, if you try and run “node -v”, you’ll get an error saying something about segmentation – in this case, you should delete all node-related files read on 🙂

Obtaining the Proper Binaries


Luckily I managed to find a proper NodeJS binary, which was compiled for ARM. You can find binaries for the different NodeJS versions on node-arm. I just grabbed the latest:

sudo dpkg -i node_latest_armhf.deb

After this, you can do

node -v

to make sure everything is OK.


Getting MongoDB was a bit harder as there aren’t any (or at least I didn’t manage to find any) binaries for ARM uploaded. In this case, I had to build the binaries myself.

Use git to get Mongo’s source code from this GitHub repository, which is especially for ARM.

git clone

To build the code, you will need the following dependencies:

sudo apt-get install scons build-essential libboost-filesystem-dev libboost-program-options-dev libboost-system-dev libboost-thread-dev libboost-all-dev

Next, compile the code!

IMRPORTANT: The compilation process on the Raspberry Pi takes a couple of hours. I started the compilation before going to bed. Also if you have a Pi with less than 512MB of RAM, it might not be enough for the compilation.

cd mongo-nonx86
sudo scons --prefix=/opt/mongo install

When these commands complete, you should have an installed MongoDB in the /opt/mongo directory.

NOTE: If you have trouble compiling the source, be sure to checkout the Building guidelines for the code. Also, I just got the latest version from the master branch, but if you need a nice and stable version with production quality, you might want to check the version branches (currently the latest version is v1.8).

Additional Info

These steps were taken from these two great blog posts:

  1. Raspberry Pi + NodeJS
  2. Install Mongodb in Raspberry Pi (here you can find additional information how to make MongoDB run at startup)


Tom Freudenberg · March 9, 2015 at 00:30


you may get your mongodb very easily from jessie repository. Just have a look at my guide to Raspbian and just follow to install mongodb.

Read more at:

Have fun

Richard Stanley · January 2, 2016 at 20:43

After four hours of compiling, your code didn’t work. I wrote a shell script that will install NodeJS, the dependencies for mongodb, and MongoDB, create a mongodb user, and add mongodb as a start up service. This script is specifically for the raspberry pi 2 because it installs the ARM7 version of Node. If you have an older pi (not version 2), you can change all the places that say “arm7,” with “arm6.”

Fabio Parigi · July 4, 2016 at 19:59

Can You share the sd image?

    Nikolay Arhangelov · July 4, 2016 at 20:45

    Hello Fabio,

    Unfortunately, I no longer have it.

    Tom Freudenberg · July 4, 2016 at 22:23

    Hello Fabio, I am still working on the fork for Meteor.js on ARM at This is a pretty good starter for a Node App and MongoDB. You may install all directly from the repo without a lot of headage. On the other hand you may take Node and Mongo directly from the Debian/Raspian apt servers.

      Fabio Parigi · July 5, 2016 at 10:52

      @Tom : I don’t know how instal from the repo

      Hi thank a lot for your reply…. I’m looking for if any one know a sd image for Raspberry Pi2 with node and mongo installed, to use like webserver in a lan
      Any one know if it exist?


Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *