Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

gyp: 'Undefined variable android_ndk_path' when building native modules on Android (Termux) without NDK

Abierto
#3,355 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
android, nodejs, python

Línea de trabajo

Empieza reproduciendo el fallo en Termux y sigue la selección de headers de node-gyp hasta el common.gypi en caché, especialmente la rama OS == "android" y su referencia a android_ndk_path. Compara esa ruta con los headers parcheados de /usr/include/node y la alternativa --nodedir; se considera terminado cuando Android sin un NDK ya no produce el fallo engañoso de variable no definida y el camino compatible elegido tiene cobertura.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Describe the bug

Building any native module with node-gyp on Android (Termux) fails with an unhelpful gyp error, even though a working toolchain (clang) is installed:

gyp: Undefined variable android_ndk_path in binding.gyp while trying to load binding.gyp

Environment: Termux on Android 15 (aarch64), Node v26.4.0, npm 12.0.2, clang 21, no NDK (Android NDK is not practical to install on Termux; the system provides its own bionic toolchain).

Root cause chain
  1. Termux's python3 reports sys.platform == "android", so gyp selects the android flavor.
  2. node-gyp does not use the headers shipped with the Node package (/usr/include/node/common.gypi, which Termux's packaging already patches for this exact issue); instead it downloads the official Node headers from nodejs.org into ~/.cache/node-gyp/<version>/.
  3. The official common.gypi has an OS == "android" branch that references <(android_ndk_path)/sources/android/cpufeatures. On a plain Android system with no NDK, android_ndk_path is undefined and gyp aborts with the message above — it reads as an internal gyp bug rather than a missing-NDK situation.
Expected behavior
  • Either node-gyp should prefer locally installed Node headers when present (Termux's /usr/include/node is a valid, already-patched header set), or
  • on Android without an NDK, emit an actionable error (e.g. "building native modules on Android requires the Android NDK, or use the system toolchain via --nodedir=/usr/include/node") instead of Undefined variable android_ndk_path.
Workaround (used successfully)

Patch ~/.cache/node-gyp/26.4.0/include/node/common.gypi: in the OS == "android" branch, replace -I<(android_ndk_path)/sources/android/cpufeatures with the system include dir. After that, node-pty and other native modules compile and link fine against the Termux bionic toolchain.

This affects every Termux user who builds native npm modules (node-pty, sharp, koffi, etc.).

Lenguaje dominante
Python
Estrellas
10.7k
Forks
1.9k
Merge medio
1 d 4 h
PR fusionados (30 d)
5

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de nodejs/node-gyp

Todos los issues de nodejs/node-gyp

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.