better-sqlite3 with pkg resulting in an error

Created on 17 Jan 2020  路  5Comments  路  Source: JoshuaWise/better-sqlite3

Hello.

node: v12.12.0
npm: v6.11.3

I'm using better_sqlite3 along with pkg to compile my node app, but after compilation I get this error:

Error: Cannot find module '../build/better_sqlite3.node'

A quick fix for that was to copy the better_sqlite3.node into the same directory as the executable was in.
That resulted in a different error, which I still can't find a way to resolve.

FATAL ERROR: v8::ToLocalChecked Empty MaybeLocal.
 1: 00007FF72AFA072F RC4_options+2829999
 2: 00007FF72AF1DF36 RC4_options+2295478
 3: 00007FF72AF1EEC6 RC4_options+2299462
 4: 00007FF72BA8CB75 RC4_options+14283509
 5: 00007FF924239E3C Require+252 [E:\Coding\NodeJS\bot-generator\node_modules\better-sqlite3\build\src\util\macros.lzz]:L124
 6: 00007FF92422B5DA RegisterModule+106 [E:\Coding\NodeJS\bot-generator\node_modules\better-sqlite3\build\src\better_sqlite3.lzz]:L36
 7: 00007FF72AF49273 RC4_options+2472435
 8: 00007FF72AF4A8E3 RC4_options+2478179
 9: 00007FF72AF49891 RC4_options+2474001
10: 00007FF72BA17150 RC4_options+13801680
11: 00007FF72BA16377 RC4_options+13798135
12: 00007FF72BA16808 RC4_options+13799304
13: 00007FF72BA165DE RC4_options+13798750
14: 00007FF72C0A02DD RC4_options+20654685
15: 00007FF72C01FD6C RC4_options+20129004
16: 00007FF72C01FD6C RC4_options+20129004
17: 00007FF72C01FD6C RC4_options+20129004
18: 00007FF72C01FD6C RC4_options+20129004
19: 00007FF72C01FD6C RC4_options+20129004
20: 00007FF72C01FD6C RC4_options+20129004
21: 00007FF72C01FD6C RC4_options+20129004
22: 00007FF72C01FD6C RC4_options+20129004
23: 00007FF72C01FD6C RC4_options+20129004
24: 00007FF72C01FD6C RC4_options+20129004
25: 00007FF72C01FD6C RC4_options+20129004
26: 00007FF72C01FD6C RC4_options+20129004
27: 00007FF72C01FD6C RC4_options+20129004
28: 00007FF72C01FD6C RC4_options+20129004
29: 00007FF72C01FD6C RC4_options+20129004
30: 00007FF72C01FD6C RC4_options+20129004
31: 00007FF72C01FD6C RC4_options+20129004
32: 00007FF72C01FD6C RC4_options+20129004
33: 00007FF72C01FD6C RC4_options+20129004
34: 00007FF72C01FD6C RC4_options+20129004
35: 00007FF72C01FD6C RC4_options+20129004
36: 00007FF72C01FD6C RC4_options+20129004
37: 00007FF72C01FD6C RC4_options+20129004
38: 00007FF72C01FD6C RC4_options+20129004
39: 00007FF72C01FD6C RC4_options+20129004
40: 00007FF72C01FD6C RC4_options+20129004
41: 00007FF72C01FD6C RC4_options+20129004
42: 00007FF72C01FD6C RC4_options+20129004
43: 00007FF72C01FD6C RC4_options+20129004
44: 00007FF72C01D321 RC4_options+20118177
45: 00007FF72C01CF0C RC4_options+20117132
46: 00007FF72B928E73 RC4_options+12826099
47: 00007FF72B928716 RC4_options+12824214
48: 00007FF72BA5783B RC4_options+14065595
49: 00007FF72AF530AE RC4_options+2512942
50: 00007FF72AF53447 RC4_options+2513863
51: 00007FF72AF51EEA RC4_options+2508394
52: 00007FF72AED1CD5 RC4_options+1983573
53: 00007FF72AF52CC3 RC4_options+2511939
54: 00007FF72AD710F1 RC4_options+538737
55: 00007FF72C1B11CC RC4_options+21772620
56: 00007FF95A337BD4 BaseThreadInitThunk+20
57: 00007FF95BE6CED1 RtlUserThreadStart+33

Thanks.

help wanted

Most helpful comment

Just making sure you've read the relevant bits in the docs

Native addons (.node files) use is supported, but packaging .node files inside the executable is not resolved yet. You have to deploy native addons used by your project to the same directory as the executable.

When a package, that contains a native module, is being installed, the native module is compiled against current system-wide Node.js version. Then, when you compile your project with pkg, pay attention to --target option. You should specify the same Node.js version as your system-wide Node.js to make compiled executable compatible with .node files.

All 5 comments

Just making sure you've read the relevant bits in the docs

Native addons (.node files) use is supported, but packaging .node files inside the executable is not resolved yet. You have to deploy native addons used by your project to the same directory as the executable.

When a package, that contains a native module, is being installed, the native module is compiled against current system-wide Node.js version. Then, when you compile your project with pkg, pay attention to --target option. You should specify the same Node.js version as your system-wide Node.js to make compiled executable compatible with .node files.

As @Prinzhorn pointed out, this is not an issue with better-sqlite3.

@DayColor Were you able to resolve this issue? I'm facing something similar. Thanks!

@DayColor Were you able to resolve this issue? I'm facing something similar. Thanks!

No, I wasn't. I eventually moved on to another project, but the issue stays unsolved.

This is fixed in v7.0.0.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

focussing picture focussing  路  4Comments

Babalon921 picture Babalon921  路  3Comments

eslachance picture eslachance  路  3Comments

k1ngrnbz picture k1ngrnbz  路  4Comments

jonataswalker picture jonataswalker  路  5Comments