Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.
This repository was archived by the owner on Jan 13, 2024. It is now read-only.

Symbol not found: _node_module_register - during dynamic link with better-sqlite3 #1155

@vadikoom

Description

@vadikoom

versions and tools invovled

  • Node 14.16.1, installed by asdf
  • pkg 5.1.0
  • better-sqlite3 7.1.15
  • target - node14-macos-x64

Here is an example that fails - https://github.com/Light-Keeper/minimal-pkg

pkg --target node14-macos-x64 ./index.js - executes well, creates index binary. But when I run it, there is an error:

➜  minimal-pkg git:(main) ./index
dyld: lazy symbol binding failed: Symbol not found: _node_module_register
  Referenced from: /Users/vyanushkevich/Projects/test/minimal-pkg/node_modules/better-sqlite3/build/Release/better_sqlite3.node
  Expected in: flat namespace

dyld: Symbol not found: _node_module_register
  Referenced from: /Users/vyanushkevich/Projects/test/minimal-pkg/node_modules/better-sqlite3/build/Release/better_sqlite3.node
  Expected in: flat namespace

[1]    73829 abort      ./index

According to this output, the .node file has been found. but, it depends on _node_module_register symbol that should be exported from node executable, but is not actually exported from the prebuilt node binary.

Here are exported symbols from the app built with pkg:

nm ./index | wc -l
4025

nm ./index | grep node_module_register # - empty outout

The same for the original node binary:

nm /Users/vyanushkevich/.asdf/installs/nodejs/14.16.1/bin/node | wc -l
72543

nm /Users/vyanushkevich/.asdf/installs/nodejs/14.16.1/bin/node | grep node_module_register
000000010007f520 T _node_module_register

I've tried renaming executable to nodejs and moving .node file next to the executable, but it did not have any effect.

Any ideas on how to overcome this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions