Skip to content

getBestNapiBuildVersion() fails on Node 23.6.0 #6

@baileympearson

Description

@baileympearson

Node 23.6.0 increased the napi version to 10 - the first napi version to have double digits. This causes getBestNapiBuildVersion (and perhaps other functions too) to fail to produce the correct version:

$ cat package.json | jq '.binary' 
{
  "napi_versions": [
    4
  ]
}
$ node --version
v23.5.0
$ node -p "require('napi-build-utils').getBestNapiBuildVersion()"
4
$ nvm use 23.6.0
$ node --version                                                 
v23.6.0
$ node -p "require('napi-build-utils').getBestNapiBuildVersion()"
undefined

The root cause is string comparison instead of numeric comparison - until we reached 10, when napiBuildVersion <= ourNapiVersion compared strings, the result was the same as though they were numbers. Now its using lexographic comparison, and napiBuildVersion <= ourNapiVersion -> '4' <= '10' -> 'false'.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions