I've been trying to integrate the serialport npm module into an electron application. I have it imported into my main process and have kept it as an external in my webpack configuration. I'm using the following:
- Node 13.2.0
- serialport 9.0.0
- electron 9.0.5
- electron-builder 22.7.0
From my package.json:
"scripts": {
"start": "electron .",
"build": "npm-run-all --parallel build:main build:renderer",
"build:main": "webpack --config ./webpack.config.main.js --mode production",
"build:renderer": "webpack --config ./webpack.config.renderer.js --mode production",
"pack": "npm run-script build && electron-builder --dir",
"dist": "npm run-script build && electron-builder"
},
"repository": "https://github.com/electron/electron-quick-start",
"build": {
"appId": "my_app",
"files": [
"build/**/*",
"node_modules/**/*"
]
},
My Problem is that when I run my "dist" script electron-builder uses what I think is the wrong chrome target. Here is the output:
• build native dependency from sources name=@serialport/bindings
version=9.0.0
platform=win32
arch=x64
reason=prebuild-install failed with error (run with env DEBUG=electron-builder to get more information)
error=prebuild-install info begin Prebuild-install version 5.3.4
prebuild-install WARN install prebuilt binaries enforced with --force!
prebuild-install WARN install prebuilt binaries may be out of date!
prebuild-install info looking for cached prebuild @ C:\Users\Me\AppData\Roaming\npm-cache\_prebuilds\90024b-bindings-v9.0.0-electron-v80-win32-x64.tar.gz
prebuild-install http request GET https://github.com/serialport/node-serialport/releases/download/@serialport/bindings@9.0.0/bindings-v9.0.0-electron-v80-win32-x64.tar.gz
prebuild-install http 404 https://github.com/serialport/node-serialport/releases/download/@serialport/bindings@9.0.0/bindings-v9.0.0-electron-v80-win32-x64.tar.gz
prebuild-install WARN install No prebuilt binaries found (target=9.0.5 runtime=electron arch=x64 libc= platform=win32)
I have yet to try and manually install the prebuilt binary into that local cache location. However, I do not know how or why electron-builder is looking for the v80 build which does not exist. The electron version 9.0.0 uses v83 for the target according to their releases, and serialport also has a v83 build here. Is there something wrong with my setup or version configuration that I'm missing here? How is electron-builder making that decision?
Other things I've tried:
- "npmRebuild = false" build flag: results in an error in the executable.
- electron-rebuild: not recommended by electron-builder