Running Node.Js on Android

MariusR picture MariusR · Apr 14, 2016 · Viewed 137.7k times · Source

So I know this has been questioned quite a lot. To be exact for example in these questions:

  1. Run NodeJs server in Android
  2. How to run my node.js project on android?
    and
  3. NodeJS on IOS/Android

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.

Answer

Pyro picture Pyro · Jan 6, 2017

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.

There is a medium post that explains the installation process

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.