termux / termux-packages

A package build system for Termux.
https://termux.dev
Other
13.01k stars 2.99k forks source link

[Bug]: Bump nodejs to satisfy npm update req #17806

Closed Leif-W closed 7 months ago

Leif-W commented 1 year ago

Problem description

[05:35:38] ~ -> npm -g i npm@10.1.0 npm ERR! code EBADENGINE npm ERR! engine Unsupported engine npm ERR! engine Not compatible with your version of node/npm: npm@10.1.0 npm ERR! notsup Not compatible with your version of node/npm: npm@10.1.0 npm ERR! notsup Required: {"node":"^18.17.0 || >=20.5.0"} npm ERR! notsup Actual: {"npm":"9.8.1","node":"v20.2.0"

What steps will reproduce the bug?

node v20.2.0 installed # current nodejs pkg npm -g i npm@10.1.0 # current max error, requires node >= v20.5.0

What is the expected behavior?

npm should be able to update itself when a supported node version is installed

System information

termix-info:

Termux Variables:
TERMUX_API_VERSION=0.50.1
TERMUX_APK_RELEASE=F_DROID
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP_PID=28021
TERMUX_IS_DEBUGGABLE_BUILD=0
TERMUX_MAIN_PACKAGE_FORMAT=debian
TERMUX_VERSION=0.118.0
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://packages.termux.dev/apt/termux-main stable main
# sources.list.d/pointless.list
deb https://its-pointless.github.io/files/24 termux extras
# root-repo (sources.list.d/root.list)
deb https://packages.termux.dev/apt/termux-root root stable
# x11-repo (sources.list.d/x11.list)
deb https://packages.termux.dev/apt/termux-x11 x11 main
# sources.list.d/rendiix.list
deb https://rendiix.github.io android-tools termux
Updatable packages:
All packages up to date
termux-tools version:
1.39.0
Android version:
13
Kernel build information:
Linux localhost 4.19.113-26203352 #1 SMP PREEMPT Tue Jul 25 17:42:44 KST 2023 aarch64 Android
Device manufacturer:
samsung
Device model:
SM-N986U1
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so
Installed termux plugins:
com.termux.api versionCode:51
sylirre commented 1 year ago

Just FYI that NPM self-upgrade is not supported by Termux. There even patch was added to disable it: https://github.com/termux/termux-packages/commit/6b05a8e7ba0435bec9afccd6e809329a7a62c27d. How you managed to bypass it that's another question.

Leif-W commented 1 year ago

@sylirre That is old news, that was an old patch, resulting from an npm limitation that was fixed in May/June, and subsequently fixed in Termux around June/July-ish? So that point is a non-issue. The referenced patch is outdated and shouldn't even be applied anymore.

sphost1 commented 11 months ago

So it's not fixed yet I'm right?

Leif-W commented 11 months ago

So it's not fixed yet I'm right?

Patch 6b05a8e was only needed as a temporary solution. There was a problem upstream with npm that arose on the Arm/Android build, due to some old script they had, dependent upon some older code, or something. The bug arose sometime around November/December-ish 2022 IIRC, part of an npm dependency cacache, was recognized/patched as a workaround in Termux in January, and was fixed upstream npm in May-ish 2023, and a bit later in the LTS version. Termux npm was bumped in July-ish but there was the cruft patch that spewed an error message that was left behind which refused to do updates. See notes on issue #13293 and look up the npm and cacache Github Issues and patches for yourselves.

In short, I think the only bug is that we erroneously still think there's a bug, and the nodejs/deps-npm-lib-commands-install.js.patch file should be deleted, and nodejs and nodejs-lts need a bump. Maybe I am wrong? But try it and see before assuming the old bug still exists? This issue #17806 and #13293 could probably be closed if a bump and patch removal fixes the issue.

Leif-W commented 10 months ago

I'm attempting to build node 21.0.0 on device. (I know there's newer patch levels but I wanted to start at 21.0.0 as a test efore moving on). Most patches that failed to apply were straightforward to resolve. I hand edited each diff, noting lines and hunk sizes. A couple patches were no longer necessary due to upstream changes. I have notes on all patch file modifications citing specific files in upstream commits. Many patches applied unmodified, though I didn't check those yet to make sure they're correct and necessary.

I get to this point with gyp complaining about undefined android_ndk_path variable. I may have missed a step? Any hints?

In cloned repo termux-packages dir, running ./build-package.sh -I nodejs.

Applying patch: tools-v8_gypfiles-toolchain.gypi.patch
Applying patch: tools-v8_gypfiles-v8.gyp.patch
Node.js configure: Found Python 3.11.6...
gyp: Undefined variable android_ndk_path in /data/data/com.termux/files/home/.termux-build/nodejs/src/node.gyp while trying to load /data/data/com.termux/files/home/.termux-build/nodejs/src/node.gyp
Error running GYP
Leif-W commented 6 months ago

The npm bug was fixed last year (about 9 months ago) as noted and referenced above, but the Termux patch to prevent npm self-update still exists.

thunder-coding commented 6 months ago

@Leif-W that patch is going to stay, manual npm updates mess with our packaged npm files. When termux is updated, those new files which newer npm version might have created will not be removed by apt, this behaviour can be problematic in some cases. Also let's not forget that Android is not a supported platform and we are just hacking node and npm to somehow work in this weird environment, its better if things are tested.

And if you want npm updates faster, separating npm from nodejs package is on my todo list already