I'm using the electron-forge webpack template. Had some issues but got serialport working.
But now when I run make to export the app, if I don't copy the node_modules folder to the exported webpack folder, when I run the app it shows serialport not found error.
I know that I must be doing something wrong in the config file, but what? I feel that's something missing.
I'm using const { SerialPort } = eval("require('serialport')");
When using const { SerialPort } = require('serialport');
I get the error 'No native build was found for platform=win32 arch=x64 runtime=electron abi=103 uv=1 libc=glibc node=16.13.2 electron=18.0.4 webpack=true'
If you are using
electron-forge
there are 2 things you need to understand.In order to use native modules like
serialport
, you have to include the modules as an external module in webpack config.If a module is listed as external, it will be pruned during the packaging process. So in your forge config, you need to include hooks during your building process.