node
node copied to clipboard
Running Node.js on a Android device
Systemless Node.js
Disclaimer
Node.js are able to read and write the entire system, I'm not responsible for any stolen data, accounts or something. Install it at your own rist!
Important!
Since version 1.1.4 requires this module Systemless mksh.rc to be installed.
Installation
mmrl install -yr node_on_android
Information
- Some binaries can't be used when
/systemit not linked into/usr. You need to charge from#!/usr/bin/env nodeto#!/system/bin/env node node-gypisn't available. Someone need to portspython- Learn more how to make
node-gypwork
- Learn more how to make
- Do not update
yarnitself. This can break the functionality.
- Please don't execute global installed binaries on boot. This module need link
/systemto/usrfirst! - This module uses an own
mkshrcfile, this causes problems with some other modules, like Terminal modifications. Be uninstalling these modules before using this!
Running service files
Files must be located in /system/etc/node.d and running on every boot after 2 minutes.
Valid file extensions:
*.js*.cjs*.mjs
Installing NPM
Since 1.1.4 NPM is useable!
# Install npm via yarn
yarn global add npm
# npm will only works when /system is into /usr linked
# If not - you have to change from "#!/usr/bin/env node" to "#!/system/bin/env node"
nano $(realpath $(which npm))
Googler's Fetcher (grf)
This is an small binary that just executes npm in a short way
Usage
grf add wget
# grf add audiotools
# grf add bash
More can you find in Googlers-Repo/addons
Module development
If you want develop global libraries for usage use please:
#!/system/bin/env node
or this (not recommended)
#!/usr/bin/env node
/systemis linked to/usrwhich makes it possible to executenpmornodemon
Installation
Node.js version: 16.15.1
Yarn version: 1.23.0
Module can be downloaded from FoxMMM. The instalation should be always be in FoxMMM.
Included binaries
yarnnode
Node API
Get some properties..
const { SystemProperties, Build } = require("android");
const id = SystemProperties.get("ro.build.id");
console.log(id);
// alternatively can you use:
console.log(Build.ID);
// List props
const props = SystemProperties.list();
// With own callback
// SystemProperties.list((prop)=> {
// console.log(prop)
// });
console.log(props);
Logging
Logging in JavaScript is 1:1 the same as in Java
const { Log } = require("android");
const TAG = "TEST";
Log.i(TAG, "Logging from JavaScript, %s!", "Kevin");
Check in logs
logcat -s TEST:*
Environment
Logging in JavaScript is 1:1 the same as in Java
const { Environment } = require("android");
const user = Environment.whoami();
const rootfs = Environment.rootfs();
const home = Environment.homedir();
const tmp = Environment.tmpdir();
console.log({
user,
home,
rootfs,
tmp,
});
// 'System.getenv()' is deprecated
const home = Environment.getenv("HOME");
console.log(home);
ROOTFS is customizable via
setprop
Example:setprop persist.mkshrc.rootfs /data/<NEW_NAME>