prebuild / prebuild

A command line tool for easily doing prebuilds for multiple version of node on a specific platform

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

N-API version undefined on Windows, leading to TypeError: expected first argument to be an array

bsrdjan opened this issue · comments

Investigating the user issue node-rfc/#162, I am getting following error, on Windows only:

PS C:\src\node-rfc> prebuild --backend cmake-js -r napi --force --strip --verbose --tag-prefix
prebuild info begin Prebuild version 10.0.0
prebuild WARN This package does not support N-API version undefined
prebuild ERR! build TypeError: expected first argument to be an array
prebuild ERR! build     at each (C:\src\node-rfc\node_modules\each-series-async\index.js:21:8)
prebuild ERR! build     at Object.<anonymous> (C:\src\node-rfc\node_modules\prebuild\bin.js:50:3)
prebuild ERR! build     at Module._compile (internal/modules/cjs/loader.js:1151:30)
prebuild ERR! build     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
prebuild ERR! build     at Module.load (internal/modules/cjs/loader.js:1000:32)
prebuild ERR! build     at Function.Module._load (internal/modules/cjs/loader.js:899:14)
prebuild ERR! build     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
prebuild ERR! build     at internal/main/run_main_module.js:17:47

PS C:\src\node-rfc> npx envinfo --system --binaries
npx: installed 1 in 1.696s

  System:
    OS: Windows 10 10.0.18363
    CPU: (2) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
    Memory: 1.46 GB / 4.00 GB
  Binaries:
    Node: 13.9.0 - C:\Tools\nvm-node\node.EXE
    npm: 6.13.7 - C:\Tools\nvm-node\npm.CMD

PS C:\src\node-rfc> prebuild -v
10.0.0

PS C:\src\node-rfc> cmake --version
cmake version 3.18.0

It just started happening on Windows, for to me unknown reason, working fine on Linux and Darwin.

To reproduce on Windows, clone the https://github.com/SAP/node-rfc master and run the above command.

Side note (doesn't explain the issue at hand): --tag-prefix is not a boolean flag. It should either be --tag-prefix foo or left out altogether if your git tags are prefixed with the default "v".

Can reproduce with node 12, but not with node 14. Which makes sense because node 12 and 13 don't support N-API 6, looking at this matrix: https://nodejs.org/api/n-api.html#n_api_n_api_version_matrix.

Can you downgrade to an earlier N-API version?

A PR is welcome to improve the error handling for this case. So that we exit before TypeError: expected first argument to be an array happens.

Thank you very much @vweevers for the prompt response. I can't downgrade to N-API 5 but have to improve the documentation, mentioning that build from source works with N-API 6 node versions versions only. Will also remove the --tag-prefix leftover, thanks for the hint.