Skip to content

Runtime information about libc version and type #39877

@Brooooooklyn

Description

@Brooooooklyn

Is your feature request related to a problem? Please describe.

I need to dectect the libc version and type on Linux systems to determined which native addon I need to load.

The most common ways in Node.js to do such things is using the detect-libc package, which is actully invoke shell scripts and try to read messages in the stdout, not elegant at all.

The other way is using try ... catch on Linux:

try {
  return require('my-native-addon.x64-linux-gnu.node')
} catch {
  return require('my-native-addon.x64-linux-musl.node')
}

not elegant either and more complicated.

Describe the solution you'd like

I want get libc information on process.versions directly, like:

console.log(process.versions.libc)

{
  family: 'glibc',
  version: '2.24'
}

For the other systems don't need to consider about libc problem, just leave the fields as null.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.stale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions