Electron running SQLlite 3 on Windows - A dynamic link library (DLL) initialization routine failed

beek

This is similar to this Electron Uncaught Error: A dynamic link library (DLL) initialization routine failed

ELECTRON_ASAR.js:173
        return old.apply(this, arguments)
                   ^

Error: A dynamic link library (DLL) initialization routine failed.
\\?\C:\workspace\client\client\desktop\node_modules\sqlite3\lib\binding\node-v57
-win32-x64\node_sqlite3.node
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
    at Object.Module._extensions..node (module.js:671:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
    at Module.load (module.js:561:32)
    at tryModuleLoad (module.js:504:12)
    at Function.Module._load (module.js:496:3)
    at Module.require (module.js:586:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\workspace\client\client\desktop\node_modules\sqlit
e3\lib\sqlite3.js:4:15)
    at Object.<anonymous> (C:\workspace\client\client\desktop\node_modules\sqlit
e3\lib\sqlite3.js:190:3)

I've tried everything suggested in this post and anything else I can find

I've installed electron-rebuild and added "rebuild": "electron-rebuild -f -w sqlite3 -V 1.7"

This is running without errors.

I tried "postinstall": "install-app-deps",

This isn't helping..

Anything else to try?

The files are in there..

enter image description here

The

willsters

This ended up being a mashup of a bunch of different issues on my end. I'll start with the simplest and go from there.

Platform

Your error there indicates that it wants node-v57-win32-x64, but if you are running from Electron it should be electron-v2.0-win32-x64 (or electron-v1.7-win32-x64 if you are using an older version). I ran into this as well because I am running sqlite3 in a child process. Child processes in Electron are in a full node context and not an Electron (browser or node+browser) context. I fixed this by passing the Electron version from the main browser process (process.versions.electron) to the child process via an environment variable and setting it on process.versions.electron in the child process.

WARNING: that is a HACK and works because I'm not using anything that expects a full Electron environment in that process. It is literally only to make it find the correct native bindings. A more correct fix would be to look into making electron-builder build node-v57-win32-x64 instead.

Speaking of which, let's create those next.

postinstall

"scripts": {
  ...
  "postinstall": "electron-builder install-app-deps"
}

This should attempt to rebuild your native dependencies when running npm install or yarn install. If you have a project/app directory, they will be placed in project/app/node_modules/. Otherwise they'll go in project/node_modules.

Transitive Dependency

In my case, sqlite3 is actually a transitive dependency of another package in my dependency set. While electron-builder on Linux/OS X picked these up correctly and showed this during installer creation:

• rebuilding native production dependencies platform=linux arch=x64
• rebuilding native dependency name=sqlite3

the Windows build showed:

• no native production dependencies

This was fixed by adding the transitive dependency as a direct dependency. After I did this, the package started to be picked up by electron-builder for compilation and was spitting out errors.

Windows Build

To fix those errors:

This is the point where I said it was "half-solved" on my end. This should be the full solution for basic electron project setups.

yarn workspaces

I use the yarn workspaces feature and my project setup is something like this:

yarn-workspace-project/
  workspace/
    project/
      web-app/
    project-electron/
      app/

For this kind of setup, yarn install is generally run in the yarn-workspace-project or yarn-workspace-project/workspace directory, rather than in each project. This produces a hoisted node_modules/ directory at yarn-workspace-project/node_modules. When creating the packaged version, electron-builder grabs the dependencies from that hoisted location and everything runs.

When running my start script in project-electron, however, electron . had some issues finding the native binding. The package using sqlite3 was installed under yarn-workspace-project/node_modules, and was therefore resolving sqlite3 to yarn-workspace-project/node_modules/sqlite3. This definitely exists per the yarn install, but the electron bindings got put in yarn-workspace-project/workspace/project-electron/app/node_modules/sqlite3.

There are multiple obvious solutions to that, so I'll leave that as an exercise to the reader. The key problem here is that the default bindings that get downloaded (I think? I don't recall them being built) for node-v57-win32-x64 do not work out of the box for Windows 10 like they do for Linux / OS X, even though the error indicates that they don't exist (which they do).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Javascript

Electron Uncaught Error: A dynamic link library (DLL) initialization routine failed

From Java

Architecturally what is the difference between a shared object (SO) and a dynamic link library (DLL)?

From

Calling Golang from Java using JNI on Windows leads to "A dynamic link library (DLL) initialization routine failed"

From Java

How to solve "Graphics Device initialization failed for : d3d, sw" when running a java Jar file with JavaFx

From Dev

Gradle sync failed: Can't load library windows-amd64\native-platform.dll

From Dev

How to link shared library *dll with CMake in Windows

From Dev

FMUException: Error loading the binary. Could not load the DLL: A dynamic link library (DLL) initialization routine failed

From Python

Cannot import from pywinauto: ImportError: DLL load failed while importing win32ui: A dynamic link library (DLL) initialization routine failed

From Dev

Dynamic link library in C

From Dev

Error while importing Tensorflow. A dynamic link library (DLL) initialization routine failed

From Dev

Compaq Visual Fortran 6.6, Dynamic-Link Library (DLL) and Module

From Dev

The ordinal 3283 could not be located in the dynamic link library libmysql.dll

From Dev

Can I force a dynamic library to link to a specific dynamic library dependency?

From Dev

Tensorflow : DLL load failed: A dynamic link library (DLL) initialization routine failed

From Dev

Pass function to dynamic link library

From Dev

Trying to use win32ui with pywin32 gives: A dynamic link library (DLL) initialization routine failed

From Dev

Server library could not be loaded and the dynamic link library LIBPQ.dll

From Dev

Is it possible for multiple Dynamic Link Libraries (DLL) to share Thread Local Storage from a Static Library (LIB)

From Dev

Could not be located in dynamic link library php4ts.dll

From Dev

The procedure entiy [email protected] could not belocated in the dynamic link library jvm.dll

From Dev

GRASS r.in.gdal crash:procedure entry point sqlite3_rtree_geometry_callback could not be located in the dynamic link library spatialite.dll

From Dev

Properties of dynamic link libraries in Windows (dll)

From Dev

How can I link dynamic library depending on another dynamic library?

From Dev

Failed to link with standard library

From Dev

Unable to link dynamic library in macOS

From Dev

The procedure entry point ... [email protected]@Qt3DRender ... could not be located in the dynamic link library ... *.dll

From Dev

C#: A dynamic link library (DLL) initialization routine failed

From Dev

How to fix Java 15 JNI "UnsatisfiedLinkError: A dynamic link library (DLL) initialization routine failed"

From Dev

Link to a dynamic link library in a cmake project

Related Related

  1. 1

    Electron Uncaught Error: A dynamic link library (DLL) initialization routine failed

  2. 2

    Architecturally what is the difference between a shared object (SO) and a dynamic link library (DLL)?

  3. 3

    Calling Golang from Java using JNI on Windows leads to "A dynamic link library (DLL) initialization routine failed"

  4. 4

    How to solve "Graphics Device initialization failed for : d3d, sw" when running a java Jar file with JavaFx

  5. 5

    Gradle sync failed: Can't load library windows-amd64\native-platform.dll

  6. 6

    How to link shared library *dll with CMake in Windows

  7. 7

    FMUException: Error loading the binary. Could not load the DLL: A dynamic link library (DLL) initialization routine failed

  8. 8

    Cannot import from pywinauto: ImportError: DLL load failed while importing win32ui: A dynamic link library (DLL) initialization routine failed

  9. 9

    Dynamic link library in C

  10. 10

    Error while importing Tensorflow. A dynamic link library (DLL) initialization routine failed

  11. 11

    Compaq Visual Fortran 6.6, Dynamic-Link Library (DLL) and Module

  12. 12

    The ordinal 3283 could not be located in the dynamic link library libmysql.dll

  13. 13

    Can I force a dynamic library to link to a specific dynamic library dependency?

  14. 14

    Tensorflow : DLL load failed: A dynamic link library (DLL) initialization routine failed

  15. 15

    Pass function to dynamic link library

  16. 16

    Trying to use win32ui with pywin32 gives: A dynamic link library (DLL) initialization routine failed

  17. 17

    Server library could not be loaded and the dynamic link library LIBPQ.dll

  18. 18

    Is it possible for multiple Dynamic Link Libraries (DLL) to share Thread Local Storage from a Static Library (LIB)

  19. 19

    Could not be located in dynamic link library php4ts.dll

  20. 20

    The procedure entiy [email protected] could not belocated in the dynamic link library jvm.dll

  21. 21

    GRASS r.in.gdal crash:procedure entry point sqlite3_rtree_geometry_callback could not be located in the dynamic link library spatialite.dll

  22. 22

    Properties of dynamic link libraries in Windows (dll)

  23. 23

    How can I link dynamic library depending on another dynamic library?

  24. 24

    Failed to link with standard library

  25. 25

    Unable to link dynamic library in macOS

  26. 26

    The procedure entry point ... [email protected]@Qt3DRender ... could not be located in the dynamic link library ... *.dll

  27. 27

    C#: A dynamic link library (DLL) initialization routine failed

  28. 28

    How to fix Java 15 JNI "UnsatisfiedLinkError: A dynamic link library (DLL) initialization routine failed"

  29. 29

    Link to a dynamic link library in a cmake project

HotTag

Archive