question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

electron-builder packages with wrong electron binary version

See original GitHub issue
  • Version: 20.44.1
  • Target: mac / snap / nsis/ appx …

I have electron@5.0.4 installed but when I package, electron-builder downloads electron@5.0.0 which is not the version I developed and tested with. This may lead to very unfortunate bugs/incompatibilities.

Details: electron-builder appears to rely on the electron version provided in package.json and ignores installed/locked versions. A version string like ^5.0.0 can be understood as 5.0.0 >= allowed versions > 6.0.0.

Example While version 5 is specified in package.json

"dependencies": {
    "electron": "^5",
    "electron-builder": "20.44.1"
}

The package manager may/will choose to install more recent packages: yarn.lock

electron@5:
  version "5.0.4"
  resolved "https://registry.yarnpkg.com/electron/-/electron-5.0.4.tgz#2e0d09055363e983f4a73317cde4821c39617b02"
  integrity sha512-7QaKorvANvP+azMT7wElx33oLlqw8QxmLs7/outfH7LC5amErk4EUtWDesQ6Zgr+s5pYFbykl8ZtJ4ZGXER05g==
  dependencies:
    "@types/node" "^10.12.18"
    electron-download "^4.1.0"
    extract-zip "^1.0.3"

yarn.lock or package-lock.json do reflect the actual used package versions.

The workaround is to set the specific electron version in the package.json dependencies, this is however not the way one normally uses the package manager since lock files exist. (and will most certainly interfere with greenkeeper and depandabot)

Just noticed this by accident, packaging using electron 5.0.0 and expecting 5.0.4 (since I specifically updated to 5.0.4) would have caused a lot of headaches.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

36reactions
sandeep1995commented, Oct 28, 2019

If you are trying to upgrade to Electron 7.0, make sure your dev dependencies is like the following

"devDependencies": {
    "electron": "7.0.0",
}

Notice it has to be 7.0.0 not ^7.0.0. The parser is poorly written.

17reactions
edmofrocommented, Feb 23, 2021

If using a yarn-workspaces based mono-repo and seeing “none of the possible electron modules are installed”, add the following to your package.json

"workspaces": {
    "nohoist": [
      "electron"
    ]
  }

This forces yarn to keep electron in the package node_modules rather than hoisting it up to the root (where electron-builder doesn’t seem to spot it)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Common Configuration - electron-builder
To package Proton Native app, set protonNodeVersion option to current or specific NodeJS version that you are packaging for. Currently, only macOS and...
Read more >
javascript - Packaging different binaries per platform for Electron
However, there are different versions of this binary that need to be packaged depending on the platform, specifically, agent.exe for Windows and ...
Read more >
Native Node Modules | Electron
prebuild provides a way to publish native Node modules with prebuilt binaries for multiple versions of Node and Electron. If the prebuild -powered...
Read more >
electron-builder | Yarn - Package Manager
A complete solution to package and build a ready for distribution Electron, Proton Native app for macOS, Windows and Linux with “auto update”...
Read more >
Packaging and distributing Electron applications using ...
electron -builder is a CLI tool that helps us create multi-platform ... developers as we normally host the application binaries on GitHub.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found