Closed Hugh-W50 closed 3 years ago
It's caused by electron-rebuild rebuilding the binaries: add "npmRebuild": "false"
to your package.json, it should fix it.
Inserting as recommended (at end of package.json) has no effect. Deploying https://www.npmjs.com/package/electron-log to trace the built app (having inserted "log.info('About to open COM1')" and replaced console.log with log.info in the port constructor call, the log file is as follows:
[2021-03-16 21:16:08.590] [info] About to open COM1
[2021-03-16 21:16:08.600] [info] Error: Third argument must be a function
It's noted that the install script in package.json is essential, with or without "npmRebuild" insertion; without automatic rebuild invocation by 'npm i' results in dev (pre-build) 'npm run start' failure: npmRunStartLog.txt
You should check this issue #2191
Confirmed that forced rebuild of serialport@9.0.7 (@TonyStark106 advice of https://github.com/serialport/node-serialport/issues/2191) eliminated the error (npm v7.6.2).
Problem introduction
This issue was first alluded to here: https://stackoverflow.com/questions/66479424/what-diagnostics-does-windows-provide-to-assist-with-electron-app-failure-to-exe. In the absence of response, the following provides explicit definition of the problem hindering progress with app build/beta test process.
Having coded and debugged an Electron app using serialport for PTZ camera control, I need advice to identify why the port used by the app - once built and installed on this Windows 10 platform - does not open/communicate, causing the app (as coded) to report comms timeout.
It is confirmed that the app executes as expected in the VS Code/npm development environment, after working around this issue: https://stackoverflow.com/questions/66605483/why-does-node-serialport-fail-when-package-json-includes-postinstall-script.
Including use of serialport.parsers.Delimiter in the JS code (for main, not renderer), the only issue now preventing progress is lack of understanding to debug the failure of the port to open in the built app context.
Summary of Problem
Code to Reproduce the Issue
serialport-related code:
package.json (same failure with alternate build script "electron-builder -w zip"):
Build log:
Versions, Operating System and Hardware
SerialPort@9.0.7
Node.js v12.18.3
Windows Version 10.0.19041
others: refer package.json above
Hardware and chipset: Gigabyte GA-B75M-D3H Intel® B75 Express Chipset (COM1 motherboard header) Processor Intel(R) Core(TM) i5-3450 CPU @ 3.10GHz, 3501 Mhz, 4 Core(s), 4 Logical Processor(s)
Please advise steps recommended to identify and overcome this issue.
In particular, to confirm the fault lies with port.open() as opposed to port.write()/on.parser() in the built context.