agentleFS
Alex72-pyAlex72-py/termux-elite/skills/node-native-build/SKILL.md

node-native-build

Skill1 starsChanged 57 days agoMITView on GitHub

Diagnose npm and Node installs that fail on Termux (node-gyp errors such as android_ndk_path, missing compilers, packages with no android binary, optional platform dependencies, out-of-memory builds) and pick the smallest fix, including WASM fallbacks. Use when npm install, yarn, pnpm, or node-gyp fails, or a package reports an unsupported platform android. Do NOT use for Python builds (see python-native-build) or for JavaScript logic errors.

  • Installs packages

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Run sh scripts/check-node-toolchain.sh.

    line 26
  2. Very specific:

    No Android binary exists for a package: prefer its WASM build when one exists (for example the -wasm variants some bundlers and image tools …

    line 33
  3. Very specific:

    Delete only files created for this attempt (for example ~/.gyp/include.gypi) and npm uninstall only packages added for it.

    line 50

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Node Native Build

Purpose

Tell apart a missing toolchain, a node-gyp configuration problem, and a package that simply ships no binary for Android, then apply the smallest fix.

When to use

  • npm install, yarn, or pnpm fails while compiling or fetching a native addon.
  • gyp ERR!, Undefined variable android_ndk_path, or Unsupported platform: android.
  • Cannot find module '@scope/pkg-android-arm64' or a similar optional dependency error.

When NOT to use

  • Python packages: python-native-build.
  • Failures in your own JavaScript.
  • pkg errors before npm ran: package-troubleshooting.

Preconditions

Run sh scripts/check-node-toolchain.sh. Capture the first gyp ERR! or build error, the package and version, and whether process.platform reports android (it does on Termux Node).

Decision tree

  1. The platform string is android, not linux. Packages that choose binaries by os and cpu may have no matching optional dependency.
  2. Undefined variable android_ndk_path in binding.gyp: node-gyp needs the variable defined. The common fix is a user include file at ~/.gyp/include.gypi containing {'variables': {'android_ndk_path': ''}}. Creating it is a confirmed change. A per-shell alternative is export GYP_DEFINES="android_ndk_path=''". Cause: Termux's Node reports its OS as android, so node-gyp enables NDK-only branches; upstream node-gyp is addressing it, so a newer node-gyp may not need the workaround.
  3. Missing compiler: node-gyp needs python, make, and clang (and pkg-config for some addons) from Termux packages.
  4. No module named 'distutils' on newer Python: use a node-gyp version that no longer needs it instead of patching Python.
  5. No Android binary exists for a package: prefer its WASM build when one exists (for example the -wasm variants some bundlers and image tools publish), a Termux-packaged equivalent, or proot with glibc. Do not fake the platform.
  6. A build that dies with Killed: lower parallelism and memory pressure (see background-processes), and raise NODE_OPTIONS=--max-old-space-size only within real device RAM.
  7. --ignore-scripts can confirm that a postinstall step is the failing part, but it leaves the addon unbuilt; say so and do not present it as the fix.
  8. Tools that hard-code /tmp fail; Termux uses $TMPDIR.

Example

  • Situation: npm install fails with Undefined variable android_ndk_path in binding.gyp.
  • Without the skill: Fakes the platform string or moves the whole project into proot.
  • With the skill: Confirms python, make, and clang are present, applies the documented fix for the missing variable after confirmation, re-runs the install, and verifies with a require.

Safety

Installing packages, creating ~/.gyp/include.gypi, and global npm installs change the environment: state the exact change and confirm. Do not run install scripts from packages the user did not choose.

Verification

Re-run the original install, then node -e "require('<package>')" and npm ls <package>.

Rollback

Delete only files created for this attempt (for example ~/.gyp/include.gypi) and npm uninstall only packages added for it.

Handoffs

  • termux-environment for architecture and Android level.
  • package-troubleshooting when installing the toolchain fails.
  • background-processes when builds are killed.
  • proot-boundaries when a glibc-only binary is required.
  • python-native-build when the failing step is a Python dependency of node-gyp.

Report

The first real error, whether it is toolchain, gyp configuration, or missing Android binary, the change applied, and the import check result.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.