Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:bug LoadLibraryExW Error when trying to compile executable using Deno and Windows #143

Open
rodryquintero opened this issue Feb 7, 2025 · 5 comments
Labels
external Issue is external to this repo
Milestone

Comments

@rodryquintero
Copy link

rodryquintero commented Feb 7, 2025

If you build any application and try to bundle it as an .exe app in Windows you get the following error.

Image

Steps to reproduce

1. Create a simple script that connects to a Duck DB database. Similar to the one below

const dbPath = 'test.db'
const instance = await DuckDBInstance.create(dbPath);
const conn = await db.connect()
const sql = 'select * from table'
const result = await conn.stream(sql);

const row = await result.getRows()
console.log(row)

2. Compile into an executable

deno compile --allow-all .\index.js

Additional info

The issue seem to be related to the library's use of native modules (found in the node-bindings direcdory).

@jraymakers
Copy link
Contributor

Using DuckDB with Node necessarily depends on native modules; DuckDB is native code. I don't know enough about Deno's compile command to know why it wouldn't bundle the native modules correctly.

The error message you included appears to be for the "classic" Node bindings for DuckDB, not for Node Neo. Could you include the error message you see for @duckdb/[email protected] (or later)?

@rodryquintero
Copy link
Author

Hello @jraymakers . I created a gist for you to try.

https://github.com/rodryquintero/deno_compile_gist

@jraymakers
Copy link
Contributor

I get a 404 when I try to follow that link.

Please include the actual error message for Node Neo. It's not easy for me to set up a development environment on Windows.

@jraymakers
Copy link
Contributor

jraymakers commented Feb 9, 2025

I was able to access the gist and try it out on a Windows machine.

The compile step works:

PS C:\Users\jephl\github\deno_compile_gist> deno compile --allow-all --output app .\index.js
Check file:///C:/Users/jephl/github/deno_compile_gist/index.js
Compile file:///C:/Users/jephl/github/deno_compile_gist/index.js to app.exe

Embedded Files

app.exe
├─┬ .deno_compile_node_modules (28.73MB - 28.72MB unique)
│ └─┬ localhost (28.73MB - 28.72MB unique)
│   └─┬ @duckdb (28.73MB - 28.72MB unique)
│     ├── node-api/* (362.69KB - 361.48KB unique)
│     ├── node-bindings/* (58.98KB - 57.9KB unique)
│     └── node-bindings-win32-x64/* (28.31MB)
├── db.js (282B)
└── index.js (251B)

Size: 28.72MB

But running the compiled app.exe hits the error:

PS C:\Users\jephl\github\deno_compile_gist> .\app.exe
error: Uncaught (in promise) TypeError: LoadLibraryExW failed
    at Object.Module._extensions..node (node:module:799:20)
    at Module.load (node:module:660:32)
    at Function.Module._load (node:module:532:12)
    at Module.require (node:module:679:19)
    at require (node:module:810:16)
    at getNativeNodeBinding (file:///C:/Users/jephl/AppData/Local/Temp/deno-compile-app.exe/.deno_compile_node_modules/localhost/@duckdb/node-bindings/1.2.0-alpha.13/duckdb.js:17:20)
    at Object.<anonymous> (file:///C:/Users/jephl/AppData/Local/Temp/deno-compile-app.exe/.deno_compile_node_modules/localhost/@duckdb/node-bindings/1.2.0-alpha.13/duckdb.js:24:18)
    at Object.<anonymous> (file:///C:/Users/jephl/AppData/Local/Temp/deno-compile-app.exe/.deno_compile_node_modules/localhost/@duckdb/node-bindings/1.2.0-alpha.13/duckdb.js:26:4)
    at Module._compile (node:module:743:34)
    at loadMaybeCjs (node:module:768:10)

Node Neo depends on DuckDB as a dynamic library. There is a DLL in node-bindings-win32-x64, duckdb.dll, that is loaded dynamically by native code. According to the compile output, this directory was included in the exe, but it seems the native code is unable to load it at runtime.

I don't know enough about Deno's compile functionality to troubleshoot further. My guess is something about the way it makes files that are embedded in the exe accessible to code doesn't work for native modules. If that's true, there's not much I can do to help. Maybe there's some configuration of Deno that would work. I think you'll need to ask for further assistance on Deno forums.

@rodryquintero
Copy link
Author

rodryquintero commented Feb 9, 2025 via email

@jraymakers jraymakers added the external Issue is external to this repo label Feb 9, 2025
@jraymakers jraymakers added this to the Limbo milestone Feb 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external Issue is external to this repo
Projects
None yet
Development

No branches or pull requests

2 participants