Issue building with node 17.0.0 but works with 17.0.1
reconbot opened this issue · comments
It looks like Node 17 had an issue with it's header files on first release which was fixed in 17.0.1. As a rule it seems prebuild pulls the first major version number and gets those headers. Because of this I think we need to special case this rule or find some other workaround.
related to #275
Is there any workaround to get prebuild to use a different release? If I use --napi --target vX.Y.Z
it compiles but then I get an NODE_MODULE_VERSION mismatch error at runtime.
To add the keywords to this issue, here is the error: /tmp/prebuild/node/17.0.0/include/node/v8-persistent-handle.h:10:10: fatal error: v8-weak-callback-info.h: No such file or directory
as experienced in https://github.com/MadLittleMods/node-usb-detection/runs/5400425223
Using the latest version of prebuild@11.0.3
running on Node.js v14.
As a workaround, you can do what @reconbot ended up doing and dropping v17 support, see serialport/node-serialport#2356
So saying --target v17.0.1
for instance would work but it is not the same as --napi
, is it? I want a NAPI build but as was pointed out in the top comment:
prebuild pulls the first major version number and gets those headers
I haven't been able to figure out how to specify what version to download for headers when specifying --napi
. Prebuild has a number of helper dependencies and I did a little digging but haven't yet found the logic for the header download.
My workaround is pretty simple: fix the abi_registry.json
file before running prebuild
.
// https://github.com/prebuild/prebuild/issues/284
const { readFileSync, writeFileSync } = require('fs');
const pathToAbiRegistry = require.resolve('node-abi/abi_registry.json');
const abiRegistry = JSON.parse(readFileSync(pathToAbiRegistry, 'utf-8'));
abiRegistry.forEach((item) => {
if (item.target === '17.0.0') {
item.target = '17.0.1';
}
});
writeFileSync(pathToAbiRegistry, JSON.stringify(abiRegistry, null, 2) + '\n');
Closing as Node.js 17 reached EOL on 2022-06-01.