tomkp / smartcard

PCSC smartcard reader library for nodejs
MIT License
134 stars 56 forks source link

Electron fails to start lib #7

Open madsbrydegaard opened 5 years ago

madsbrydegaard commented 5 years ago

Using Electron 4 I cant start the smartcard lib on Windows 10 It works well when using node in start script...

Part of error log: 10 silly lifecycle electron.card-loader@0.0.1~start: Args: [ '/d /s /c', 'electron .' ] 11 silly lifecycle electron.card-loader@0.0.1~start: Returned: code: 3228369023 signal: null 12 info lifecycle electron.card-loader@0.0.1~start: Failed to exec start script 13 verbose stack Error: electron.card-loader@0.0.1 start: electron . 13 verbose stack Exit status 3228369023 13 verbose stack at EventEmitter. (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16) 13 verbose stack at EventEmitter.emit (events.js:182:13) 13 verbose stack at ChildProcess. (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14) 13 verbose stack at ChildProcess.emit (events.js:182:13) 13 verbose stack at maybeClose (internal/child_process.js:962:16) 13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5) 16 verbose Windows_NT 10.0.17134 17 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "start" 18 verbose node v10.14.2 19 verbose npm v6.4.1 20 error code ELIFECYCLE 21 error errno 3228369023 22 error electron.card-loader@0.0.1 start: electron . 22 error Exit status 3228369023

simosalsi commented 2 years ago

I had a similar problem and even though this issue is 3 years old I'm hoping this might help someone.

I created and packaged my Electron app using electron-forge, the build was made with the Squirrel maker.

Installing the app on my machine would, of course, yield no problems. On my client's machine though, it would install (failing to create a shortcut but that's irrelevant) but launching the app would result in no response (a process would start, but no window would show).

Turns out the problem was me calling "const devices = new Devices()" in the file I used to contain all smart card functions (let's say SmartCardReader.js), outside of any functions, so right after imports.

Moving the line to declare "devices" inside of each function solved the issue. This does mean that in each function I had to wait for onActivated() before doing anything with the reader, since "devices" does not get populated by the constructor.

I would venture to guess that one could set a "devices" variable to null right after imports and have a function initialize it before using the variable inside other functions.

I haven't tried this yet though, so take it at face value.

Hope this helps, have a nice day everyone!