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?
versions and tools invovled
asdfHere is an example that fails - https://github.com/Light-Keeper/minimal-pkg
pkg --target node14-macos-x64 ./index.js- executes well, createsindexbinary. But when I run it, there is an error:According to this output, the
.nodefile has been found. but, it depends on_node_module_registersymbol 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:
The same for the original node binary:
I've tried renaming executable to
nodejsand moving.nodefile next to the executable, but it did not have any effect.Any ideas on how to overcome this?