fix(main/nodejs{,-lts}): auto-configure node-gyp for native modules#27724
fix(main/nodejs{,-lts}): auto-configure node-gyp for native modules#27724ggdev-ops wants to merge 3 commits intotermux:masterfrom
Conversation
Configure npm settings in postinst for Termux native compilation: - Add python to TERMUX_PKG_DEPENDS - Set npm config: python, nodedir, arch, platform - Install check-gyp-deps.sh helper script at $PREFIX/share/nodejs/ Enables 'npm install <native-module>' without manual configuration.
|
|
||
| # Target architecture and platform | ||
| npm config set arch $NPM_ARCH | ||
| npm config set platform android |
There was a problem hiding this comment.
Could you provide an example of what specific npm install command that has an error would be fixed by this change?
I think I remember there being a command that has an error, but I forgot what it was. If you put it in the PR description, that would help.
| # Check for node-gyp build dependencies in Termux | ||
| # Usage: $PREFIX/share/nodejs/check-gyp-deps.sh | ||
|
|
||
| MISSING="" |
There was a problem hiding this comment.
I think this code should be indented to the same level as the other heredoc in this file.
| fi | ||
| python tools/install.py install --dest-dir="" --prefix "${TERMUX_PREFIX}" --build-dir "$_BUILD_DIR" | ||
|
|
||
| # Install helper script to check node-gyp build dependencies |
There was a problem hiding this comment.
I don't think this is going to help much. It's just going to end up as a script which is neither used by anyone nor that useful. All these dependencies are already in TERMUX_PKG_SUGGESTS, so they should be installed unless the user decides to go without suggested dependencies.
| # linker, which does not use symbols of linked shared libraries when resolving | ||
| # symbols on dlopen(). See https://github.com/termux/termux-packages/issues/462. | ||
| TERMUX_PKG_DEPENDS="libc++, openssl, c-ares, libicu, libsqlite, zlib" | ||
| TERMUX_PKG_DEPENDS="libc++, openssl, c-ares, libicu, libsqlite, zlib, python" |
There was a problem hiding this comment.
python is already in TERMUX_PKG_SUGGESTS, no need to keep it in two places
| # linker, which does not use symbols of linked shared libraries when resolving | ||
| # symbols on dlopen(). See https://github.com/termux/termux-packages/issues/462. | ||
| TERMUX_PKG_DEPENDS="libc++, openssl, c-ares, libicu, libsqlite, zlib" | ||
| TERMUX_PKG_DEPENDS="libc++, openssl, c-ares, libicu, libsqlite, zlib, python" |
|
Hi everyone I wish you solve this problem with "npm install -g node-gyp"
this depends on the following pkgs python ndk-sysroot openssl
libandroid-support libandroid-spawn binutils whether the user installed
these or not it needs to configure the paths manual configuration all users
need to to add paths manually
…On Mon, Dec 22, 2025, 10:58 AM Yaksh Bariya ***@***.***> wrote:
***@***.**** requested changes on this pull request.
------------------------------
In packages/nodejs/build.sh
<#27724 (comment)>
:
> @@ -195,11 +195,65 @@ termux_step_make_install() {
_BUILD_DIR+="/Release/"
fi
python tools/install.py install --dest-dir="" --prefix "${TERMUX_PREFIX}" --build-dir "$_BUILD_DIR"
+
+ # Install helper script to check node-gyp build dependencies
I don't think this is going to help much. It's just going to end up as a
script which is neither used by anyone nor that useful. All these
dependencies are already in TERMUX_PKG_SUGGESTS, so they should be
installed unless the user decides to go without suggested dependencies.
------------------------------
In packages/nodejs-lts/build.sh
<#27724 (comment)>
:
> @@ -11,7 +11,7 @@ TERMUX_PKG_AUTO_UPDATE=false
# Note that we do not use a shared libuv to avoid an issue with the Android
# linker, which does not use symbols of linked shared libraries when resolving
# symbols on dlopen(). See #462.
-TERMUX_PKG_DEPENDS= <#462.-TERMUX_PKG_DEPENDS=>"libc++, openssl, c-ares, libicu, libsqlite, zlib"
+TERMUX_PKG_DEPENDS="libc++, openssl, c-ares, libicu, libsqlite, zlib, python"
python is already in TERMUX_PKG_SUGGESTS, no need to keep it in two places
------------------------------
In packages/nodejs/build.sh
<#27724 (comment)>
:
> @@ -10,7 +10,7 @@ TERMUX_PKG_AUTO_UPDATE=false
# Note that we do not use a shared libuv to avoid an issue with the Android
# linker, which does not use symbols of linked shared libraries when resolving
# symbols on dlopen(). See #462.
-TERMUX_PKG_DEPENDS= <#462.-TERMUX_PKG_DEPENDS=>"libc++, openssl, c-ares, libicu, libsqlite, zlib"
+TERMUX_PKG_DEPENDS="libc++, openssl, c-ares, libicu, libsqlite, zlib, python"
Same comment as earlier
—
Reply to this email directly, view it on GitHub
<#27724 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/B3QDLQGGZB4JENH72SC6IDT4C6QBBAVCNFSM6AAAAACPWVLQ7OVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZTMMBSHE4DOOJZHE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Configure npm for native module compilation on install: - Set arch, platform, nodedir for node-gyp - Set python, cc, cxx, ar, strip paths - Warn user if build tools are missing Fixes: npm install <native-module> fails without manual config
What This PR SolvesEvery Termux user who runs
Current Workaround (manual, every user must do monthly)Users must manually export 10+ environment variables in their shell config:
What This PR DoesAutomates Step 3 in the postinst script (runs when nodejs is installed):
Addressed Review Feedback
|
|
Just I see this I do remember there was an error with a different command, but I still don't remember what command that was, could you clarify that? |
Configure npm settings in postinst for Termux native compilation:
Enables 'npm install ' without manual configuration.