TryGhost / node-sqlite3

SQLite3 bindings for Node.js
BSD 3-Clause "New" or "Revised" License
6.23k stars 817 forks source link

Bundled build error on Windows #1758

Open damms005 opened 9 months ago

damms005 commented 9 months ago

Issue Summary

I develop and build my VS Code extension on my Linux machine.

It uses sqlite3 to connect to SQLite databases.

However, some Windows users have node error that the node sqlite3 build is not a valid Win32 application

image

Details in this issue: https://github.com/damms005/devdb-vscode/issues/46

I build and deploy the code from my Linux machine.

How do I address this please?

Steps to Reproduce

  1. Download the extension from the marketplace
  2. Install a new Laravel appliation
  3. Open the Laravel application codebase on a Mac OS machine
  4. Open the extension view
  5. See the error

Version

5.1.7

Node.js Version

v20.3.0

How did you install the library?

Bundled in the extension as explained in teh steps above

CodingBear-Git commented 9 months ago

@damms005 Hello! I also encountered this. This error occurs because you are developing on a PC running Linux. When you run the npm install sqlite3 command, a build only for Linux OS is installed in the \node_modules\sqlite3\lib\binding directory. For me, the solution was to manually download builds (here: https://github.com/TryGhost/node-sqlite3/releases/tag/v5.1.6) for other OS (windows for example) and upload them here: \node_modules\sqlite3\ lib\binding For example: \node_modules\sqlite3\lib\binding\napi-v6-linux-musl-x64 \node_modules\sqlite3\lib\binding\napi-v6-win32-unknown-x64

But this solution only works for version 5.1.6 and below. This doesn't work in version 5.1.7. I created an issue about this here https://github.com/TryGhost/node-sqlite3/issues/1754

I hope I helped somehow, good luck!

damms005 commented 9 months ago

Thanks for the clarification, @CodingBear-Git. I thought as much, but I do not have any proof or read about it anywhere.

Two questions:

  1. Per the manual download you explained, does it mean you were downloading binaries in code at runtime?
  2. Do you think this cross-platform compatibility is what @lovell is talking about here: https://github.com/lovell/sharp/issues/3985#issuecomment-1933617702 ?
CodingBear-Git commented 9 months ago

@damms005

  1. I have a node js application. I'm using https://github.com/vercel/pkg to make a binary file (For example, .exe for Windows). When I create a binary, my node_modules directory is included in the file. And inside node_modules there are already sqlite3 assemblies for all the systems that I support.
  2. I think not, but I'm not sure. I don't have much experience :)
damms005 commented 9 months ago

Thanks for your detailed response, @CodingBear-Git .

Per #1754, it seems you are also having this cross-platform issue.

I also evidently do not have very deep experience with Node.js.

However, it seems @lovell's comment that I posted above is a likely way out and I will update you here if I find anything worthwhile.