prebuild-install fails to determine target on Node 23.6.0 #203
Description
On the latest node (23.6.0), prebuild-install fails to install native packages that specify napi versions in the package.json (and maybe other configurations too) - prebuild-install reports a target of undefined
. Ex:
$ npm i @mongodb-js/zstd
npm error code 127
npm error path /~/dev/mongoose/node_modules/@mongodb-js/zstd
npm error command failed
npm error command sh -c prebuild-install --runtime napi || npm run clean-install
npm error > @mongodb-js/[email protected] clean-install
npm error > npm run install-zstd && npm run compile
npm error
npm error
npm error > @mongodb-js/[email protected] install-zstd
npm error > bash etc/install-zstd.sh
npm error prebuild-install warn This package does not support N-API version undefined
npm error prebuild-install warn install No prebuilt binaries found (target=undefined runtime=napi arch=arm64 libc= platform=darwin)
npm error bash: etc/install-zstd.sh: No such file or directory
npm error A complete log of this run can be found in: /~/.npm/_logs/2025-01-13T16_59_21_577Z-debug-0.log
(note: we realize that this package should be buildable from source, we plan to fix this separately).
Notice that the inferred target
is undefined:
target=undefined runtime=napi arch=arm64 libc= platform=darwin)
This behavior is not present on Node versions <23.6.0.
The bug actually lies in napi-build-utils
(I filed inspiredware/napi-build-utils#6 too) but that package seems long dead, so I'm filing an issue here as well.
The root cause is that 23.6.0 increased the napi version to 10, which breaks the logic in getBestNapiBuildVersion()
, which uses string comparison instead of numeric comparison.