Sponsored by Gluten Free Waffles and Sliced Bananas

Wednesday, May 28, 2014

How I Got Node.js and MongoDB running on Android

1:44 PM Posted by Tyson Nero , , , 23 comments
This past Memorial Day Weekend, I gave myself a personal challenge (derived from a project at work) of deploying a Node.js application using MongoDB to an Android device. After a quick Google search, I realized that such a task was not a simple one, but rather it was going to take a lot of research, trial and error, and not a lot of sleep.

For starters, neither Node.js or MongoDB have support for Android. Even more frustrating, they both do not have installs for ARM processors. My first step was to figure out if anyone had already installed Node.js on Android, and if so, how they did it. The first article I came across with this claim was by Masashi Katsumata: Node.js on Android. Based on the directions and comments, I believed this strategy would work and devised a plan:
  1. Buy an inexpensive tablet
  2. Root the device
  3. Install Debian
  4. Install Node.js
  5. Install MongoDB
  6. Deploy and run the application
Buy an Inexpensive Tablet

My next step was finding a cheap tablet. My choices at hand were Walmart and Best Buy. After visiting them both, I picked up a $70 Visual Land Prestige Pro 7D from Best Buy. Now, I was ready to rock, but truly didn't realize what I was in store for.

Root the Device (Visual Land Prestige Pro 7D)

With such an obscure device, there was not a lot of support for figuring out how to root it. I first came across a video claiming the Visual Land tablets come rooted but not advertised as such. I downloaded Root Checker, and quickly realized that was not true. Luckily, TabletRoms.com had a couple forum threads dedicated to rooting my specific device. The first tutorial was using Vroot, however, I would not recommend this method as it's reported to install adware, some Chinese apps, and modify the Super User. The other option was to follow a tutorial using Cydia Impactor. After following the instructions, I ran Root Checker again, and this time, the device was successfully rooted. I also installed several helpful tools listed below which made this whole process much simpler.

  1. Download Cydia Impactor 
  2. Follow rooting instructions here: http://www.tabletroms.com/forums/pro-7d/6932-%5Btut%5D-how-root-vl-prestige-pro-7d-easiest-method.html
Other Recommended Installs:
Install Debian

To install Debian Kit, I first downloaded the Debian Kit app on Google play. This doesn't actually install Debian Kit, but runs pre-checks and supplies the needed files and instructions. From there, I followed a couple of tutorials from the author and successfully installed Debian. To my demise though, I began running out of disk space as I progressed, and needed to re-install using a partitioned SD card instead.

  1. Download Debian Kit app on Google play
  2. Format and partition and SD card giving yourself ample space for the Debian install (recommended)
    1. Here's a good tutorial: How to Partition your Android MicroSD Card
  3. Install Debian Kit (read all)
    1. Basic instructions: http://sven-ola.dyndns.org/repo/debian-kit-en.html
    2. Instructions (includes SD card): http://www.doviak.net/debian-kit/HowTo-SvenOla-DebianKit.pdf
    3. See step 2 here: http://masashi-k.blogspot.com/2013/08/nodejs-on-android.html
Install Node.js

Firstly, there is Android build support starting in Node v0.11.3 (beta):

Regardless, versions before 0.11.3 do  support building Node for ARM architecture.

I came across a tutorial using Node Version Manager to install the beta version with Android support: https://gist.github.com/jtenner/79bb5350c318f7623ca7. However, it failed to work on my device most likely because nvm didn't compile for ARM.

Following this tutorial: http://masashi-k.blogspot.com/2013/08/nodejs-on-android.html, I opted to build and install an earlier version of Node. Since I was dealing with an ARM processor, the install had to be configured with special arguments. I also ran into a strange error to do with "blx" requiring minor modification of Node source code. Luckily, the tutorial addressed both problems, and Node.js was finally built and installed.

  1. Follow step 3 here: http://masashi-k.blogspot.com/2013/08/nodejs-on-android.html
    1. Note the steps for ARM architecture
      #> ./configure --without-snapshot --dest-cpu=arm --dest-os=linux
  2. If you get this error "For thumb inter-working we require an architecture which supports blx",  you must customize the macro-assembler-arm.cc file.
    Try either of these options:
    1. http://www.yoovant.com/install-node-0-10-on-arm-based-board/
    2. http://www.yoovant.com/how-install-node-js-0-8-arm-based-sbc-fox-board-g20/

Install MongoDB

This is where the nightmare officially began. Not only can MongoDB not be installed on ARM architecture but it cannot be built for it either. There's an existing issue created in Mongo's official tracker, however it's currently unassigned: https://jira.mongodb.org/browse/SERVER-1811. Reading the comments, however, revealed some clues including several forks of Mongo that supposedly build and install for ARM:
After building and installing the first three above, waiting 3-4 hrs for each, and them failing somewhere in the process, I was ready to give up. Then, I came across one final article: Building MongoDB on Raspberry Pi. With mongo-nonx86, I was able to compile and install flawlessly making my application stack complete.

  1. Read the comments on Mongo's open issue for ARM support
  2. Choose a fork to build and install (follow respective instructions):
    1. https://github.com/RickP/mongopi
    2. https://github.com/wtfuzz/mongo-arm
    3. https://github.com/skrabban/mongo-nonx86 (worked for me)
  3. Or, use these pre-compiled binaries: https://github.com/Barryrowe/mongo-arm

Deploy and Run the Application

Getting the application to the device is rather easy:

  1. Copy the application files to a free partition on the SD Card 
  2. USB transfer
  3. Git clone (if publicly available)

It is recommended to deploy files that were freshly pulled from source control before npm install has been run. Native dependencies are built for the platform during install time. If you copy a native module built on Windows to Linux for instance, you will have issues during run-time.

Once the files are on your device, execute npm install and make sure everything completes.

Finally, fire up your node server making sure any database connections are successful.


  1. Hey Now Ty

    Stellar post! Thx 4 the info.

  2. Hi Tyson,

    Nice post. I have followed these and other instructions to get my hp slate 7 to run debian and has nodejs compiled and working. I need to use the serialport library to listen to serial output from a scale via a serial to usb converter. This works fine on a pc, however I do not seem to be able to get the usb port on the android device. Would you be able to point me in the right direction. On a pc running debian, i use /dev/ttyUSB0 for the serial to usb device ... however I do not get this device coming up when I plug the same working device into the tablet .

  3. but node.js was running on debian not android. that is not your goal, right?

  4. did you get npm to work?

    I installed debiabkit on a mk902 minipc a few months ago and tried to compile node

    after a few attempts died complaining about something that looked like it was cpu specific I eventually found a version that looked like it worked.

    node seems ok

    but not npm

    if I try to install anything with npm i get a segmentation fault

    how do I install a node app that is normally installed by using npm without a working npm on the device?

    btw debiankit is great
    .. install a vnc viewer app and can use debian gui apps too.

    also has apt-get, aptitude, etc and most things just work

  5. actually - trying it again found that npm does seem to mostly work but there is some strange issue with file permissions .. the segfault seems to be happening when it can't write

  6. Can i use search4roots rooting tool for step number 2.??

  7. Nice sharing. MongoDB is a widely used open source database system. Scop for mongodb is increasing day by day. Learn MongoDB Training from expert reach gangboard. Selenium Training

  8. you don't need to do all these Hassel to run node.js in android . you can find my tutorial : https://kickwe.com/tutorial/clone-git-repository-made-node-js-using-android/

    1. and to be precise tutorial about nodejs in android <a href="https://kickwe.com/tutorial/installing-running-node-js-android/>running and installing nodejs in android </a>

  9. Hey With Your Instruction's Successfully Installed the One,Great Explanation and Nice Blog,,,thanks for writing......
    Thanks@Selenium Online Training

  10. Pretty blog, so many ideas in a single site, thanks for the informative article, keep updating more article.
    Software testing course in chennai

  11. Its an incredible joy perusing your post. It's brimming with data I am searching for and I want to post a remark that "The substance of your post is marvelous" Great work.
    android app development courses in chennai

  12. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Front end developer learn from Javascript Training in Chennai . or learn thru Javascript Training in Chennai. Nowadays JavaScript has tons of job opportunities on various vertical industry. JavaScript Training in Chennai

  13. Nice and good article. It is very useful for me to learn and understand easily. Thanks for sharing your valuable information and time. Please keep updating.
    Web Design Training

  14. Really I Appreciate The Effort You Made To Share The Knowledge. This Is Really A Great Stuff For Sharing. Keep It Up . Thanks For Sharing.

    MongoDB Developer and Admin Training

    Node JS Training

  15. Very good post.
    All the ways that you suggested for find a new post was very good.
    Keep doing posting and thanks for sharing
    mobile repairing course in hyderabad

  16. Nice post. Thanks for sharing! I want people to know just how good this information is in your article. It’s interesting content and Great work.
    Thanks & Regards,
    VRIT Professionals,
    No.1 Leading Web Designing Training Institute In Chennai.

    And also those who are looking for
    Web Designing Training Institute in Chennai
    SEO Training Institute in Chennai
    PHP & Mysql Training Institute in Chennai
    Photoshop Training Institute in Chennai
    Android Training Institute in Chennai