简体   繁体   中英

A dynamic link library (DLL) initialization routine failed in electron with nodegit

When I use nodegit in electron, I got the error when I start the app:

App threw an error during load

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

\\?\\D:\\Electron\\hello\\node_modules\\nodegit\\build\\Release\\nodegit.node

at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:166:20)

at Object.Module._extensions..node (internal/modules/cjs/loader.js:740:18)

...

I can use nodegit in nodejs successfully, but failed in electron.

Even I added .npmrc file with content below, it's still faield.

runtime = electron
target = 1.2.8
target_arch = x64
disturl = https://atom.io/download/atom-shell

Does anyyone know how to fix it in electron? My environment is windows 10 x64 with vs 2017, node 10.13, electron 3.010

I had the same problem with another node package using electron 3.0.6 and eventually got it working.

Try these:

  1. Make sure the packages are listed under the dependencies and not devDependencies in the package.json

  2. Add this "electron-rebuild --force node-gyp rebuild --target=3.0.6 --arch=x64" to postinstall under the scripts section. I ended up with this in my packages.json (my DLL error was for "printer")

     { "name": "myproject", "version": "1.0.0", "main": "main.js", "scripts": { "postinstall": "electron-rebuild --force node-gyp rebuild --target=3.0.6 --arch=x64", "start": "electron ." }, "dependencies": { "@types/node": "^10.12.18", "electron-rebuild": "1.8.2", "electron": "3.0.6", "printer": "0.2.2" }, "devDependencies": { ... } } 

See here for more info

Hope this helps someone

From this link :

The most common issue though is that the component was not properly installed, so that some of its dependencies are not available.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM