NodeJS + MongoDB Web Server Raspberry Pi Tutorial

How to Install a NodeJS Web Server using Mongo DB on your Raspberry Pi

1. Install NVM (Node Version Manager)

curl -o- | bash

2. Update Bash Profile

This will give you the ability to install NodeJS versions (comes with npm).

echo 'PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin"' >> ~/.bashrc

echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.bashrc

echo '[ -s "$NVM_DIR/" ] && . "$NVM_DIR/"' >> ~/.bashrc

source ~/.bashrc

3. Install a NodeJS Version

Using NVM, we will install NodeJS and be able to access node and npm commands.

nvm install 5.9.1

nvm use 5.9.1

nvm alias default 5.9.1

4. Check Installations

Verify that you have done the previous steps below.

npm --version

node -v

5. Install MongoDB, Create Database, and Update config/database.js localUrl

Now we will install MongoDB so that you can have a Mongo Database on your Raspberry Pi.

sudo apt-get install mongodb-server -y

sudo mkdir -p /data/db

sudo service mongodb start

Now you have to update your database config file for the directory we just created in /data/db.

This is what my ~/projects/node-todo/config/database.js file looks like:

module.exports = {
    remoteUrl : 'mongodb://',
    localUrl: 'mongodb://localhost/db'

6. Grab Node-ToDo files from Github

This is a beginner project created by

git clone

cd node-todo

7. Install Packages

Install the node packages via npm. This may take a minute or two so go grab a coffee. 🙂

npm install

8. Edit Config and Startup the Server!

node server.js

9. View Your Application


or to access from a computer on the same network


10. I can’t find my IP Address…

ifconfig | grep inet
pi@raspberrypi:~/projects/node-todo $ ifconfig | grep inet
inet addr: Bcast: Mask:

You want the first IP address shown after inet addr. Mine is You can now head to http: to view your application!

In the terminal, you should see all HTTP requests to your Raspberry Pi.


Please comment below if you would like to see more tutorials like this, or have any questions!

1 Response

  1. RPi Admin says:

    Please feel free to comment if you would like to see more tutorials (advanced or similar)!

Leave a Reply

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

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