'Webpack not including module with Electron Forge and SerialPort

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'



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source