Hello,
I have some trouble packaging for windows an electron app with pcsc-mini : it fails to load the pcsc-mini module when doing a require / import.
I'm asking here but I don't know if it's a problem with the packager itself (electron-builder).
I have this simple js application that is run by electron and I try to package it as standalone app for linux and windows :
const {log, error} = require('electron-log');
try {
log('starting app');
require( "pcsc-mini");
log('pcsc-mini module loaded successfully');
} catch (e) {
error('Failed to load pcsc-mini module: ' + e.message);
error(e)
}
Results:
No problem on linux, I can build and execute the generated AppImage .
On windows I'm able only to execute the app using yarn electron src/index.js : I'm unable to package it properly because it can't find the native module in addon.node.js.
Here is the execution log on windows when the app is a standalone .exe:
23:40:01.000 > starting app
23:40:01.099 > Failed to load pcsc-mini module: Required addon dependency not found (@pcsc-mini/windows-x86_64-electron):
Error: The specified module could not be found.
\?\C:\Users\dolly\AppData\Local\Temp\34RGWp2IIbMeJ6QvWoHxJtnesmN\resources\app.asar.unpacked\node_modules@pcsc-mini\windows-x86_64-electron\addon.node
ΓÜá NOTE: If optional dependencies are disabled, you may need to add @pcsc-mini/windows-x86_64-electron as an explicit dependency.
23:40:01.103 > Error: Required addon dependency not found (@pcsc-mini/windows-x86_64-electron):
Error: The specified module could not be found.
\?\C:\Users\dolly\AppData\Local\Temp\34RGWp2IIbMeJ6QvWoHxJtnesmN\resources\app.asar.unpacked\node_modules@pcsc-mini\windows-x86_64-electron\addon.node
ΓÜá NOTE: If optional dependencies are disabled, you may need to add @pcsc-mini/windows-x86_64-electron as an explicit dependency.
at Object.<anonymous> (C:\Users\dolly\AppData\Local\Temp\34RGWp2IIbMeJ6QvWoHxJtnesmN\resources\app.asar\node_modules\pcsc-mini\build\addon.node.js:64:9)
at Module._compile (node:internal/modules/cjs/loader:1714:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1848:10)
at Module.load (node:internal/modules/cjs/loader:1448:32)
at Module._load (node:internal/modules/cjs/loader:1270:12)
at c._load (node:electron/js2c/node_init:2:17993)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:244:24)
at Module.require (node:internal/modules/cjs/loader:1470:12)
at require (node:internal/modules/helpers:147:16)
To summarize
- The problem is that the file C:\Users\dolly\AppData\Local\Temp\34RGWp2IIbMeJ6QvWoHxJtnesmN\resources\app.asar.unpacked\node_modules@pcsc-mini\windows-x86_64-electron\addon.node exists on the disk (I can do fs.statSync on it from the app without problem);
- I'm able to use this app and the native module with electron (
yarn electron src/index.js is OK);
- I'm not able to use this app when it's packaged (execution of the result of
yarn electron-builder is KO on windows);
- If I cheat and replace the addon.node file by another valid nodule (for instance the old pcsclite), the generated package seems to work.
I'm using pcsc-mini version 0.1.3
I tried node 24 with electron 36 and electron-builder 0.26 (I also tried node 18 with electron 19 and electron-builder 0.24)
Does someone have an example of a pcsc-mini working in a packaged electron application ?
Am I missing something ?
Here is a folder with the code
bug-electron-builder-pcsc-mini.zip
I spent the full day trying to tweak the configuration of electron builder without any luck and any help would be greatly appreciated.
Hello,
I have some trouble packaging for windows an electron app with pcsc-mini : it fails to load the pcsc-mini module when doing a
require / import.I'm asking here but I don't know if it's a problem with the packager itself (electron-builder).
I have this simple js application that is run by electron and I try to package it as standalone app for linux and windows :
Results:
No problem on linux, I can build and execute the generated AppImage .
On windows I'm able only to execute the app using
yarn electron src/index.js: I'm unable to package it properly because it can't find the native module in addon.node.js.Here is the execution log on windows when the app is a standalone .exe:
To summarize
yarn electron src/index.jsis OK);yarn electron-builderis KO on windows);I'm using pcsc-mini version 0.1.3
I tried node 24 with electron 36 and electron-builder 0.26 (I also tried node 18 with electron 19 and electron-builder 0.24)
Does someone have an example of a pcsc-mini working in a packaged electron application ?
Am I missing something ?
Here is a folder with the code
bug-electron-builder-pcsc-mini.zip
I spent the full day trying to tweak the configuration of electron builder without any luck and any help would be greatly appreciated.