Skip to content

feat: lazy electron download#49328

Merged
jkleinsc merged 5 commits into
electron:mainfrom
erickzhao:lazy-download
Feb 20, 2026
Merged

feat: lazy electron download#49328
jkleinsc merged 5 commits into
electron:mainfrom
erickzhao:lazy-download

Conversation

@erickzhao

@erickzhao erickzhao commented Jan 7, 2026

Copy link
Copy Markdown
Member

Description of Change

First pass at implementing electron/rfcs#22.

This PR spawns a separate Node.js child process running the existing install.js script for the binary download to minimize the diff in the code. Now, there are two ways to get the binary installed:

  • npx electron will automatically trigger install.js if the Electron binary path is missing.
  • npx install-electron will manually trigger install.js.

The error hint now adds the --no flag to explicitly prevent installation of the install-electron package (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/npm and bypassing the version and checksum checks.

cc @MarshallOfSound

Checklist

Release Notes

Notes: 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-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Jan 7, 2026
@erickzhao erickzhao added no-backport semver/major incompatible API changes labels Jan 7, 2026
Comment thread npm/index.js
const pathFile = path.join(__dirname, 'path.txt');

function downloadElectron () {
console.log('Downloading Electron binary...');

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open to bikeshedding on the exact message or just removing the logging altogether if it feels spammy.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could include a link to the installation docs with this message, similar to how React includes links for errors.


## Running Electron ad-hoc

If you're in a pinch and would prefer to not use `npm install` in your local

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lowkey I think we should remove this npx instruction set from the doc.

@erickzhao erickzhao marked this pull request as ready for review January 8, 2026 23:42
@erickzhao erickzhao requested a review from a team as a code owner January 8, 2026 23:42

@samuelmaddock samuelmaddock left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API LGTM

@reitowo reitowo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API LGTM

@jkleinsc jkleinsc merged commit 19d0c07 into electron:main Feb 20, 2026
62 checks passed
@release-clerk

release-clerk Bot commented Feb 20, 2026

Copy link
Copy Markdown

Release Notes Persisted

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.

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
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
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 <jan.dubois@suse.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants