Running Node.Js on Android
So I know this has been questioned quite a lot. To be exact for example in these questions:
Every option presented has a problem though:
I want to run it on my normal device so I would like to avoid installing another OS on my Device
Work on JXCore was stopped last month and (maybe as a result) I couldn't get it to compile (see Can't install jxcore-cordova)
- The Android Port of NodeJs Anode has not been worked on since 2014 and wasn't really maintained back then anyways
- The second answer in the second thread I linked to mentioned there is an official node distribution for Android now but apart from a link to the Browse-Website of the latest dist I couldn't find any info on how to actually use it
- I also saw this but it seems like the device has to be connected to a PC (or similar) to run the adb shell commands while I would like to make it as a separate App
With the time that past since these questions have been posted and as the "best option" JXCore seem to be now unusable: Is there a way to run a node.js application (a server in my case) on an Android device?
if you're wondering why I'd want this: I made a WebApp with a Node.Js server and I now want a version you can launch locally from your phone without requiring an Internet connection. This means the server needs to run on an Android phone.
I just had a jaw-drop moment - Termux allows you to install NodeJS on an Android device!
It seems to work for a basic Websocket Speed Test I had on hand. The http served by it can be accessed both locally and on the network.
Basically: 1. Install termux 2. apt install nodejs 3. node it up!
One restriction I've run into - it seems the shared folders don't have the necessary permissions to install modules. It might just be a file permission thing. The private app storage works just fine.
Great New Application No Need to root your Phone and You Can Run your js File From anywere.
- API Documents and instant code run from doc
- syntax highlighting code editor
- npm supports
- linux terminal(toybox 0.7.4). node.js REPL and npm command in shell (add '--no-bin-links' option if you execute npm in /sdcard)
- StartOnBoot / LiveReload
- native node.js binary and npm are included. no need to be online.
Update instruction to node js 8 (async await)
Download node.js v8.3.0 arm zip file and unzip.
copy 'node' to android's sdcard(/sdcard or /sdcard/path/to/...)
open the shell(check it out in the app's menu)
cd /data/user/0/io.tmpage.dorynode/files/bin (or, just type cd && cd .. && cd files/bin )
cp /sdcard/node .
(chmod a+x node
J2V8 is best solution of your problem. It's run Nodejs application on jvm(java and android).
J2V8 is Java Bindings for V8, But Node.js integration is available in J2V8 (version 4.4.0)
You can use Node.js for Mobile Apps.
It works on Android devices and simulators, with pre-built binaries for armeabi-v7a, x86, arm64-v8a, x86_64. It also works on iOS, though that's outside the scope of this question.
Like JXcore, it is used to host a Node.js engine in the same process as the app, in a dedicated thread. Unlike JXcore, it is basically pure Node.js, built as a library, with a few portability fixes to run on Android. This means that it's much easier to keep the project up to date with mainline Node.js.
Full disclosure: I work for the company that develops Node.js for Mobile Apps.
the tutorial of how to build NodeJS for Android https://github.com/dna2github/dna2oslab/tree/master/android/build there are several versions v0.12, v4, v6, v7
It is easy to run compiled binary on Android; for example run compiled Nginx: https://github.com/dna2github/dna2mtgol/tree/master/fileShare
You just need to modify code to replace Nginx to NodeJS; it is better if using Android Service to run node js server on the backend.