Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run NodeJs server in Android

Is it possible to run NodeJs server in android device (like linux devices not android apps).

If possible please help me to do it.

And is it possible to start mongo server on Android device?

My devices:

  • RK3288 TV Box (android 4)
  • Asus fonepad 7 (android 5 root)
  • LG Optimus G (android 4 root)

Important!! I want to start a server app in android. because I have an unused android TV-Box and I want to use it in my home server

And I don't want to use it in APK files (to load html files in WebView s). I need nodejs server not javascript client with CommonJs and RequireJs

like image 656
Hossain Khademian Avatar asked Jun 29 '15 08:06

Hossain Khademian


People also ask

Can I run NodeJS on Android?

Node. js for Mobile Apps is a Node. js runtime that runs on Android and iOS, using the V8 JavaScript engine. It is very similar to a Linux build of Node, but with a few platform-specific tweaks and fixes.

How do I run a node js server?

The usual way to run a Node. js program is to run the globally available node command (once you install Node. js) and pass the name of the file you want to execute. While running the command, make sure you are in the same directory which contains the app.

CAN node js be used as a server?

Node. js is an open source server environment.

Is Node JS good for mobile?

Node. js also allows developers to share data easily between the server-side and client-side. It is one of the most popular platforms for building fast and scalable mobile, and web applications.


1 Answers

You might want to install a chrooted-linux on your android-device, as explained here.

In short, do this:

  1. prepare linux-image
    1. do this on any gnu+linux -device.
    2. create a big file (>1 GB)
    3. format it as a filesystem (eg. ext2)
    4. mount it.
    5. copy a distribution inside of it (e.g. with debootstrap)
  2. copy loopdevice to android
  3. mount it (root required)
    1. maybe install busybox
    2. attach some directories from the root-device to the host (usually dev, dev/pts, proc and sys )
  4. chroot
  5. install nodejs inside chroot

note: I have done something similar to my tf301 and it works like a charm. But when I start to use too much memory inside the chroot (e.g. when compiling an android-app), the host will crash. I have not yet experienced those crashes with node and I do not know, if other devices are affected by this.

like image 163
wotanii Avatar answered Nov 07 '22 06:11

wotanii