Electron-builder: cannot build native dependency

Created on 2 Sep 2019  Â·  7Comments  Â·  Source: electron-userland/electron-builder


  • Version: 21.2.0

  • Target: Windows x64



I am trying to package a small project, which has serialport respectively @serialport/bindings.
I am developing on macOS (Mojave). The build/packaging for Mac is working fine.
The native dependency will be re-built.

When packaging for Windows, I get the following error:

• electron-builder  version=21.2.0 os=18.7.0
  • loaded configuration  file=package.json ("build" field)
  • writing effective config  file=release/builder-effective-config.yaml
  • rebuilding native dependencies  dependencies=@serialport/[email protected] platform=win32 arch=x64
  • install prebuilt binary  name=@serialport/bindings version=2.0.8 platform=win32 arch=x64
  ⨯ cannot build native dependency  reason=prebuild-install failed with error and build from sources not possible because platform or arch not compatible
                                    cause=exit status 1
                                    errorOut=prebuild-install info begin Prebuild-install version 5.3.0
    prebuild-install info looking for cached prebuild @ /Users/ph/.npm/_prebuilds/a3ea41-bindings-v2.0.8-electron-v73-win32-x64.tar.gz
    prebuild-install http request GET https://github.com/node-serialport/node-serialport/releases/download/v2.0.8/bindings-v2.0.8-electron-v73-win32-x64.tar.gz
    prebuild-install http 404 https://github.com/node-serialport/node-serialport/releases/download/v2.0.8/bindings-v2.0.8-electron-v73-win32-x64.tar.gz
    prebuild-install WARN install No prebuilt binaries found (target=6.0.7 runtime=electron arch=x64 libc= platform=win32)

                                    command=/usr/local/Cellar/node/12.8.0/bin/node /Users/ph/Documents/Project/node_modules/prebuild-install/bin.js --platform=win32 --arch=x64 --target=6.0.7 --runtime=electron --verbose --force
                                    workingDir=/Users/ph/Documents/Project/node_modules/@serialport/bindings
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I tried to package for Linux also for testing purpose, but I got the same error.
I can only package for macOS.

Most helpful comment

@phhoef obviously you've got 404: prebuild-install http 404 https://github.com/node-serialport/node-serialport/releases/download/v2.0.8/bindings-v2.0.8-electron-v73-win32-x64.tar.gz

Try disabling rebuild by adding "npmRebuild": false, to your build config.

All 7 comments

@phhoef obviously you've got 404: prebuild-install http 404 https://github.com/node-serialport/node-serialport/releases/download/v2.0.8/bindings-v2.0.8-electron-v73-win32-x64.tar.gz

Try disabling rebuild by adding "npmRebuild": false, to your build config.

@defusioner thanks for your reply.
I am really no expert and your answer confuses me. I thought, I do have to re-build the native dependencies for each build to match with the Electron version? Could you please explain, why the npmRebuld flag could solve this issue?

Anyhow, I followed your suggestion and actually it seems that now the pre-built packages are going to download. Unfortunately it finally still fails.

  • electron-builder  version=21.2.0 os=18.7.0
  • loaded configuration  file=package.json ("build" field)
  • writing effective config  file=release/builder-effective-config.yaml
  • skipped dependencies rebuild  reason=npmRebuild is set to false
  • packaging       platform=win32 arch=x64 electron=6.0.7 appOutDir=release/win-unpacked
  • downloading     url=https://github.com/electron/electron/releases/download/v6.0.7/electron-v6.0.7-win32-x64.zip size=61 MB parts=8
  • downloaded      url=https://github.com/electron/electron/releases/download/v6.0.7/electron-v6.0.7-win32-x64.zip duration=5.061s
  • downloading     url=https://github.com/electron-userland/electron-builder-binaries/releases/download/winCodeSign-2.5.0/winCodeSign-2.5.0.7z size=5.6 MB parts=1
  • downloaded      url=https://github.com/electron-userland/electron-builder-binaries/releases/download/winCodeSign-2.5.0/winCodeSign-2.5.0.7z duration=2.448s
  • building        target=MSI arch=x64 file=release/Project 1.0.0.msi
  • building        target=nsis file=release/Project Setup 1.0.0.exe archs=x64 oneClick=true perMachine=false
  • downloading     url=https://github.com/electron-userland/electron-builder-binaries/releases/download/nsis-3.0.3.2/nsis-3.0.3.2.7z size=1.4 MB parts=1
  • downloading     url=https://github.com/electron-userland/electron-builder-binaries/releases/download/wix-4.0.0.5512.2/wix-4.0.0.5512.2.7z size=2.2 MB parts=1
  • downloaded      url=https://github.com/electron-userland/electron-builder-binaries/releases/download/nsis-3.0.3.2/nsis-3.0.3.2.7z duration=2.107s
  • downloading     url=https://github.com/electron-userland/electron-builder-binaries/releases/download/nsis-resources-3.4.1/nsis-resources-3.4.1.7z size=731 kB parts=1
  • downloaded      url=https://github.com/electron-userland/electron-builder-binaries/releases/download/nsis-resources-3.4.1/nsis-resources-3.4.1.7z duration=2.111s
  • building block map  blockMapFile=release/Project Setup 1.0.0.exe.blockmap
  • downloaded      url=https://github.com/electron-userland/electron-builder-binaries/releases/download/wix-4.0.0.5512.2/wix-4.0.0.5512.2.7z duration=36.653s
  ⨯ cannot execute  cause=exit status 103
                    out=WiX Toolset Linker version 4.0.0.5512
Copyright (c) .NET Foundation and contributors. All rights reserved.


                    errorOut=wine: cannot find L"C:\\windows\\system32\\winemenubuilder.exe"
    err:wineboot:ProcessRunKeys Error running cmd L"C:\\windows\\system32\\winemenubuilder.exe -a -r" (2)
    Z:\Users\ph\Documents\Project\release\__msi-x64\project.wxs(256) : error LGHT0103 : The system cannot find the file 'Z:\Users\ph\Documents\Project\release\win-unpacked/resources/app.asar.unpacked/node_modules/dblsqd-electron/node_modules/electron/dist/Electron.app/Contents/Frameworks/Squirrel.framework/Headers'.

                    command=/Users/ph/Library/Caches/electron-builder/wine/wine-2.0.3-mac-10.13/bin/wine 'Z:\Users\ph\Library\Caches\electron-builder\wix\wix-4.0.0.5512.2\light.exe' -out 'Z:\Users\ph\Documents\Project\release\Project 1.0.0.msi' -v -spdb -sw1076 '-dappDir=Z:\Users\ph\Documents\Project\release\win-unpacked' -pedantic -wx -sval project.wixobj
                    workingDir=
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I am not sure, if I get the error message.
Is it necessary, that I install wine? I am wondering, because in other projects, it was never necessary to install wine. I am not sure, what's different now. I used the electron-react-boilerplate for the first time. Also, this is my first typescript project.

@phhoef Can't get you more help right now, sorry, I've got the same 404 problem (but for another dependency) and resolved it with no reinstall flag.

I think the problem was, that there are no rebuilds of serialport for that Electron version.
I downgraded Electron and it now seems to work ...

@defusioner thanks! Your solution worked for me when trying to build an electron app with SerialPort for windows with a docker image: electronuserland/builder:wine
Thanks a lot!

@defusioner thanks! you save my day!

What "no reinstall" flag is being referred to here? I can't find one in the documentation or in Zulip discussions

Was this page helpful?
0 / 5 - 0 ratings