Repository navigation
feat: lazy electron download - #49328
Merged
Merged
Conversation
erickzhao
commented
Jan 7, 2026
| const pathFile = path.join(__dirname, 'path.txt'); | ||
|
|
||
| function downloadElectron () { | ||
| console.log('Downloading Electron binary...'); |
Member
Author
There was a problem hiding this comment.
Open to bikeshedding on the exact message or just removing the logging altogether if it feels spammy.
Member
There was a problem hiding this comment.
Maybe we could include a link to the installation docs with this message, similar to how React includes links for errors.
erickzhao
commented
Jan 8, 2026
|
|
||
| ## Running Electron ad-hoc | ||
|
|
||
| If you're in a pinch and would prefer to not use `npm install` in your local |
Member
Author
There was a problem hiding this comment.
Lowkey I think we should remove this npx instruction set from the doc.
jkleinsc
approved these changes
Feb 20, 2026
|
Release Notes Persisted
|
3 tasks done
kycutler
pushed a commit
to kycutler/electron
that referenced
this pull request
Feb 26, 2026
* feat: lazy electron download * better error messaging? * add breaking changes script doc * add binary download step to install instructions * respect no binary env var
3 tasks done
3 of 6 tasks
KristjanESPERANTO
pushed a commit
to MagicMirrorOrg/MagicMirror
that referenced
this pull request
May 6, 2026
additional things: - removed fix chrome-sandbox permissions (runs without) - added `npx install-electron` which downloads the electron binaries new in v42: > Electron now downloads its binary into node_modules dynamically on first launch instead of running a postinstall script. Added the install-electron script to manually trigger the download as well. electron/electron#49328
3 of 5 tasks
jandubois
added a commit
to rancher-sandbox/rancher-desktop
that referenced
this pull request
May 13, 2026
Electron 42 dropped its postinstall download (electron/electron#49328). Invoke the new install-electron bin so the Linux chrome-sandbox chmod finds the binary. Signed-off-by: Jan Dubois <[email protected]>
itsbkm
added a commit
to FreeOpenSourcePOS/FloCafe
that referenced
this pull request
Jul 28, 2026
Root cause of the release-mac failures on v2.4.1/v2.4.2: Electron 43 removed its automatic postinstall download as a supply-chain hardening measure (electron/electron#49328) and now only fetches its binary lazily, the first time the electron CLI is actually launched. npm ci never launches electron, so node_modules/electron/dist stayed empty in CI and verify-electron-runtime.sh correctly caught it. postinstall now runs the replacement install-electron bin script first to force an eager download. Verified locally: moving node_modules/electron/dist aside and running node_modules/.bin/install-electron directly re-populates Electron.app. Also reverts v2.4.2's temporary --foreground-scripts CI diagnostics now that the cause is known, and documents the lazy-download change in CONTRIBUTING.md. Co-Authored-By: Claude Sonnet 5 <[email protected]>
rsimmermon
added a commit
to rsimmermon/Sertum
that referenced
this pull request
Sep 9, 2026
…tinstall Electron 42 removed the postinstall script that downloaded the binary during npm install (electron/electron#49328). The package now fetches itself the first time require('electron') asks for the executable path, which is what electron-forge start does. dev-app-name.js runs from postinstall, before anything has asked, and read node_modules/electron/dist, so on macOS every fresh npm install failed with ENOENT on that directory. Windows never noticed because the branding script exits early off Darwin and the first npm start downloaded the binary. scripts/ensure-electron.js now runs ahead of the branding in postinstall and prestart. It goes through require('electron') rather than install.js so a dev bundle already renamed to Sertum.app is left alone instead of fetched again. dev-app-name.js reports a missing dist in one line instead of a stack trace, and AGENTS.md records the constraint.
rezacr588
added a commit
to rezacr588/electron
that referenced
this pull request
Oct 27, 2026
npm/index.js joins ELECTRON_OVERRIDE_DIST_PATH with the executable path listed in path.txt, and falls back to a bare "electron" when there is no path.txt (added in electron#25377 for installs that skip scripts). That is only the right file name on Linux. The executable is Electron.app/Contents/MacOS/Electron on macOS and electron.exe on Windows. Since electron#49328 removed the postinstall script, path.txt does not exist until the binary is first downloaded, so a fresh install with the override set always hits that fallback. The override also skips the download, so require('electron') and the electron command kept pointing at a file that does not exist. Fall back to the executable path of the current platform instead, and add a spec for how npm/index.js resolves the executable path. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
5 tasks done
MarshallOfSound
pushed a commit
that referenced
this pull request
Nov 10, 2026
npm/index.js joins ELECTRON_OVERRIDE_DIST_PATH with the executable path listed in path.txt, and falls back to a bare "electron" when there is no path.txt (added in #25377 for installs that skip scripts). That is only the right file name on Linux. The executable is Electron.app/Contents/MacOS/Electron on macOS and electron.exe on Windows. Since #49328 removed the postinstall script, path.txt does not exist until the binary is first downloaded, so a fresh install with the override set always hits that fallback. The override also skips the download, so require('electron') and the electron command kept pointing at a file that does not exist. Fall back to the executable path of the current platform instead, and add a spec for how npm/index.js resolves the executable path. Co-authored-by: Claude Sonnet 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Change
First pass at implementing electron/rfcs#22.
This PR spawns a separate Node.js child process running the existing
install.jsscript for the binary download to minimize the diff in the code. Now, there are two ways to get the binary installed:npx electronwill automatically triggerinstall.jsif the Electron binary path is missing.npx install-electronwill manually triggerinstall.js.The error hint now adds the
--noflag to explicitly prevent installation of theinstall-electronpackage (which we've stubbed in the registry just in case).I tested this manually by initializing a new npm project pointing to
file:path/to/src/electron/npmand bypassing the version and checksum checks.cc @MarshallOfSound
Checklist
npm testpassesRelease Notes
Notes: Electron now downloads its binary into
node_modulesdynamically on first launch instead of running apostinstallscript. Added theinstall-electronscript to manually trigger the download as well.