tojocky / node-printer

Native node.js printer
1.54k stars 443 forks source link

Not a valid Win32 Application in Electron #167

Closed alexmccabe closed 7 years ago

alexmccabe commented 7 years ago

No matter what I try, I get the error

Uncaught Error: %1 is not a valid Win32 application.
\\?\C:\Users\IEUser\Desktop\electron-print\resources\app\node_modules\printer\build\Release\node_printer.node`

I have tried building the code in multiple ways

node-gyp rebuild --target=0.37.4 --arch=x64 --dist-url=https://atom.io/download/atom-shell
npm install printer --runtime=electron --target=1.4.1 --target_arch=x64
npm install printer --runtime=electron --target=1.4.1 --target_arch=ia32

npm install printer --msvs_version=2013  --build-from-source=node_printer
.\node_modules\.bin\electron-rebuild.cmd

I just cannot get this to work on any version of Windows 10 (64-bit or 32-bit). I managed to get it to work on OSX just fine.

I have Visual Studio 2013 installed as well as Python 2.7.13. The build process appears to work, but then in Electron I get the above error.

tojocky commented 7 years ago

Try VS 2015

alexmccabe commented 7 years ago

RIGHT, weirdly, I ran

npm install printer --msvs_version=2013  --build-from-source=node_printer
.\node_modules\.bin\electron-rebuild.cmd

again, and this time I have a different error, but I seem to be closer. The error I now have is ELECTRON_ASAR.js:168 Uncaught Error: Module version mismatch. Expected 49, got 53.

I must've done something wrong on the previous installation attempts.

EDIT: I have run .\node_modules\.bin\electron-rebuild.cmd and .\node_modules\.bin\electron-rebuild.cmd --target=1.4.1 and I haven't resolved the issue. Any ideas?

tojocky commented 7 years ago

This may help you https://github.com/electron/electron/blob/master/docs/tutorial/using-native-node-modules.md

alexmccabe commented 7 years ago

For posterity the following worked

cd node_modules\printer
node-gyp rebuild --target=1.3.14 --arch=x64 --dist-url=https://atom.io/download/atom-shell

Looks like I was using incorrect version numbers for this.

Thank you for your help.

cotufaloschiflones commented 6 years ago

For posterity as well, this was my experience with this same issue using node-printer from my mac compiling for windows.

https://github.com/electron/electron/issues/1075#issuecomment-362220859