serialport / node-serialport

Access serial ports with JavaScript. Linux, OSX and Windows. Welcome your robotic JavaScript overlords. Better yet, program them!
https://serialport.io
MIT License
5.82k stars 1.01k forks source link

Build Error on Different Platforms (serialport & electron) #2720

Open dkarski opened 1 year ago

dkarski commented 1 year ago

SerialPort Version

10.5.0

Node Version

18.16.1

Electron Version

26.4.0

Platform

Darwin MacBook-Pro-Appnroll-3.local 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar 6 21:00:17 PST 2023; root:xnu-8796.101.5~3/RELEASE_X86_64 x86_64

Architecture

x86/x64

Hardware or chipset of serialport

No response

What steps will reproduce the bug?

  1. Clone the dkarski:electron-serialport:electron-builder project repository.
  2. Run the application on a Mac system.
  3. Try to build (an application on a Mac system) and run the application on a Windows system.

What happens?

When I try to run the application on a Windows system that has been built on a Mac system, the application behaves incorrectly and displays the following error in the console. However, when I build the application on Windows, it runs without any issues.

Uncaught Error: \\?\C:\Users\Daniel Karski\AppData\Local\Programs\electron-serialport\resources\app.asar.unpacked\node_modules\@serialport\bindings-cpp\build\Release\bindings.node is not a valid Win32 application.
\\?\C:\Users\Daniel Karski\AppData\Local\Programs\electron-serialport\resources\app.asar.unpacked\node_modules\@serialport\bindings-cpp\build\Release\bindings.node

What should have happened?

I would expect the application to work correctly on a Windows system, regardless of the system on which it was built.

Additional information

In my case, I used the electron-builder tool for building the application, but a similar issue occurs when using other tools such as electron-forge with webpack or Vite. It appears that the build tool is not the primary cause of the issue described.

It's important to note that when I build the application on Windows, it runs without any issues. The problem seems to be specific to building the application on a Mac and then running it on Windows.

I would appreciate any assistance in resolving this problem, as it hinders the development and testing of the application on different platforms.

Thank you for your attention and assistance!

GazHank commented 1 year ago

I'm not sure if electron-builder supports cross build of a windows app from MacOS. The only cross build scenario that I can see in the documentation is building on Linux to target windows https://www.electron.build/multi-platform-build.html#to-build-app-for-windows-on-linux

I wonder if a docker container would let you work around this limitation?