NodeJS On IOS/Android
Solution 1:
Yes you can with JXCore (a fork of nodejs), more info in this link Build Mobile Apps with JavaScript and the Node.js Ecosystem repository is in here.
And how to compile it is in here JXCore - How to Compile
But if you need it to be nodejs (not the last version) you can use this link to do what you need Building and running Node.js for Android
UPDATED 27-09-2018
Like someone has pointed out, that project is no longer maintained but I have found and alternative by Using Termux on an Android phone you can use nodejs / gcc / vim / etc and more tools to do many thing
This link show how to do it for nodejs ( and I have tested it on my phone ): Building a Node.js application on Android - Part 1: Termux, Vim and Node.js
First install termux from playstore, of course.
Solution 2:
I don't understand the point of using a server tool on the client side.
If your application should work with an offline mode, you should put all data and other in your client app (using cordova).
If your application works with an online mode the server side is needed to serve your data. Here you can setup a nodeJS API which provides routes for your application to have content to print.
I'm not sure I brought you the wanted answer, so can explain more the point of using a server tool on a client device?
Solution 3:
What you are trying to achieve, turns your device into a server.
A server side language is meant to stay on the server. I don't really see why you need to open a localhost socket on the device to communicate with itself. Is it for offline testing? You can do that since you have a computer and a device, and both are connected to the same network. I believe a really good start would be understanding the concept of the Client-Server architecture first.
But in short, the proper way of implementing a Client-Server app using your chosen technologies would be: A server should provide the client with answers to his requests. So in Node.js (server-side), write whatever you want to communicate with your database (Create, Read, Update, Delete), do custom processing, etc... and return a structured answer.
The client is expecting answers to his requests, and is supposed to handle the answers in code. So the program written in AngularJS (which is your client-side language) will be installed on devices.
The client has to know the format of the server's answer. Is it plain text? XML? JSON? ...
Solution 4:
so you mean you would like to have an app can run some services via http?
not sure if iOS allows application with JS virtual machine executing code ...
and for Android
searching on Github and I find how to build NodeJS for Android
https://github.com/dna2github/dna2oslab/tree/master/android/build
Here is an example to run compiled Nginx binary on Android at https://github.com/dna2github/dna2mtgol/tree/master/fileShare
You may modify a little more to replace Nginx to NodeJS. The code to run Nginx is not very nice; maybe you can try an Android Service to let the server run on backend on Android device.
Hope it is what you want.
Post a Comment for "NodeJS On IOS/Android"