MatteoMeil / node-native-printer

Node module to print from nodejs apps
83 stars 41 forks source link

Could not load windows_printer.dll #8

Closed ThomasKranitsas closed 5 years ago

ThomasKranitsas commented 5 years ago

After building my electron app using electron-builder --win --ia32 --x64, running the installed executable throws a Could not load windows_printer.dll. File could not be found error.

I can see the windows_printer.dll file in the AppData\Local\Programs\<APP NAME>\resources\app.asar.unpacked\node_modules\node-native\printer\lib\windows

Am I missing any step? Any ideas?

MatteoMeil commented 5 years ago

What version of electron are you using?

ThomasKranitsas commented 5 years ago

"electron": "^2.0.2"

ThomasKranitsas commented 5 years ago

@MatteoMeil any update here?

MatteoMeil commented 5 years ago

I built a project time ago with an older version of Electron (1.x) and all went well. These days I haven't so much time but as soon as possible I'll try with newer version

ThomasKranitsas commented 5 years ago

Please give it a try once you find some time. This is a blocker for me. Thanks!

gino8080 commented 5 years ago

same problem here :(

ThomasKranitsas commented 5 years ago

Hi @MatteoMeil, did you have time to look into that?

weavc commented 5 years ago

@ThomasKranitsas

Slightly hacky fix, but a fix nonetheless for us was to alter the following in src/windows_printer.js:

var dllPath = fs.realpathSync(__dirname + '/../lib/windows/windows_printer.dll');
if (fs.existsSync('./resources/app.asar.unpacked/node_modules/node-native-printer/lib/windows/windows_printer.dll')) {
    dllPath = fs.realpathSync('./resources/app.asar.unpacked/node_modules/node-native-printer/lib/windows/windows_printer.dll');
}

And then adding the --asar.unpack=*.dll flag instead of --asar=true in our electron-packager command.

It's not perfect, but it now runs as expected in both our live and dev builds and hopefully helps someone else out.

MatteoMeil commented 5 years ago

I'm sorry for this long period of absence due to a lot of work and study.

I took a look around and I manage to understand that this problem is releated to edge.js and every other fork (see this issue).

So, getting ideas from @ChrisWeaver1's comment, I will add a flag to correctly get the path in production.