Skip to content

Magisk-Modules-Alt-Repo/node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node.js

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

Via MMRL or via the MMRL CLI

mmrl install -yr node_on_android

Information

  • Some binaries can't be used when /system it not linked into /usr. You need to charge from #!/usr/bin/env node to #!/system/bin/env node
  • node-gyp isn't available. Someone need to ports python
  • Do not update yarn itself. This can break the functionality.
  • Please don't execute global installed binaries on boot. This module need link /system to /usr first!
  • This module uses an own mkshrc file, 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

/system is linked to /usr which makes it possible to execute npm or nodemon

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

  • yarn
  • node

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>