bun
bun copied to clipboard
bug: Electron failed to install correctly
What version of Bun is running?
0.2.2
What platform is your computer?
Darwin 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct 9 20:15:09 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T6000 arm64 arm
What steps can reproduce the bug?
Install electron
with bun then try to exec you project with bun run start
How often does it reproduce? Is there a required condition?
It happens evey times
What is the expected behavior?
Electron should be installed properly by bun
What do you see instead?
throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again');
^
Error: Electron failed to install correctly, please delete node_modules/electron and try installing again
at getElectronPath (/node_modules/electron/index.js:17:11)
at Object.<anonymous> (/node_modules/electron/index.js:21:18)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Module.require (node:internal/modules/cjs/loader:1061:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (/node_modules/electron/cli.js:3:18)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
Node.js v18.12.1
Script error "start" exited with 1 status
Additional information
package.json
{
"name": "test",
"module": "index.js",
"type": "module",
"scripts": {
"start": "electron ."
},
"devDependencies": {
"electron": "^22.0.0"
}
}
We'll take a look at this, it's possible that electron
is manually checking the node_modules/
folder and we may need to submit a patch for it to work with Bun.
Hello, guys! Just came to tell that this still happens on v0.5.7.
bun run electron
/home/gabriel/Documents/VSCode/personal/hmr-electron/node_modules/electron/index.js:17
throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again');
^
Error: Electron failed to install correctly, please delete node_modules/electron and try installing again
at getElectronPath (/home/gabriel/Documents/VSCode/personal/hmr-electron/node_modules/electron/index.js:17:11)
at Object.<anonymous> (/home/gabriel/Documents/VSCode/personal/hmr-electron/node_modules/electron/index.js:21:18)
at Module._compile (node:internal/modules/cjs/loader:1218:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
at Module.load (node:internal/modules/cjs/loader:1081:32)
at Module._load (node:internal/modules/cjs/loader:922:12)
at Module.require (node:internal/modules/cjs/loader:1105:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (/home/gabriel/Documents/VSCode/personal/hmr-electron/node_modules/electron/cli.js:3:18)
at Module._compile (node:internal/modules/cjs/loader:1218:14)
Node.js v18.13.0
error: "electron" exited with code 1 (SIGHUP)
still happens on v0.6.7
/home/lucasp/Downloads/my-electron-app/node_modules/electron/index.js:17
throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again');
^
Error: Electron failed to install correctly, please delete node_modules/electron and try installing again
at getElectronPath (/home/lucasp/Downloads/my-electron-app/node_modules/electron/index.js:17:11)
at Object.<anonymous> (/home/lucasp/Downloads/my-electron-app/node_modules/electron/index.js:21:18)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/home/lucasp/Downloads/my-electron-app/node_modules/electron/cli.js:3:18)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
error: script "start" exited with code 1 (SIGHUP)
but the command
bun start
works after npm install
with a little search on folders some files is missing on bun install in compare with npm i
npm i
bun install
and I make a test adding a path.txt file but does't works because of is missing dist folder
and anothers folders maybe adding this files on bun install works
Still happening on v0.7.3
The postinstall
hook for electron
calls node install.js
, which downloads electron and writes a file called path.txt by its package.json
https://github.com/electron/electron/blob/main/npm/install.js#L87
@Jarred-Sumner could it be that bun isn't running that script, or that it's being downloaded elsewhere?
This is in a yarn workspace
What does
bun --bun run dev
result in?
Weird error about a directory that exists not existing
Also regardless the file path.txt
doesn't exist in the electron node_modules folder, something clearly went wrong during bun install
The postinstall hook for electron calls node install.js, which downloads electron and writes a file called path.txt by its package.json
Related to
- https://github.com/oven-sh/bun/issues/606
- https://github.com/oven-sh/bun/pull/4263
This is a blocker for us using Bun unfortunately. Our app works fine when we install electron
with Yarn, but with bun we get this error. Definitely need the NPM postinstall scripts to run, as adding electron
as a trustedDependencies
didn't seem to do anything.
Luckily looks like this would be resolved very soon in PR#5077, looking forward to that being merged!
- https://github.com/oven-sh/bun/pull/5077
Duplicate of #4959
Fixed by @dylan-conway and @paperdave in #7132
This will be part of the Bun v1.0.17 release, which ships in a few hours from the time of writing.
Thank you and keep up with the hard work :)
Is now fixed ! @Jarred-Sumner
This error still shows if electron is installed globally as a dependency. I had to run the postinstall
script manually
same with bun 1.1.17, im using docker oven/bun bun install
at emit (node:events:180:48)
5.756 at emitReadable_ (node:stream:1957:27)
5.756 at onEofChunk (node:stream:2046:24)
5.756 at readableAddChunk (node:stream:1983:30)
5.756 at <anonymous> (node:stream:3361:21)
5.756 at _flush (node:crypto:1225:13)
5.756 at final (node:stream:3359:19)
5.756
5.756 error: postinstall script from "electron" exited with 1
------
failed to solve: process "/bin/sh -c bun install" did not complete successfully: exit code: 1
This is supposedly a security feature, not a bug. Post install scripts are deliberately not run on bun installs.
These scripts are arbitrary shell commands that the package manager is expected to read and execute at the appropriate time. But executing arbitrary scripts represents a potential security risk, so—unlike other npm clients—Bun does not execute arbitrary lifecycle scripts by default.
https://bun.sh/docs/install/lifecycle
Still having this issue on windows
12 | return path.join(process.env.ELECTRON_OVERRIDE_DIST_PATH, executablePath || 'electron');
13 | }
14 | if (executablePath) {
15 | return path.join(__dirname, 'dist', executablePath);
16 | } else {
17 | throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again');
^
error: Electron failed to install correctly, please delete node_modules/electron and try installing again
at getElectronPath (C:\Users\K29xzPosq0gTfbHv\AppData\Local\REDACTED\app\node_modules\electron\index.js:17:11)
at C:\Users\K29xzPosq0gTfbHv\AppData\Local\REDACTED\app\node_modules\electron\index.js:21:18
at C:\Users\K29xzPosq0gTfbHv\AppData\Local\REDACTED\app\node_modules\electron\cli.js:3:7
Bun v1.1.20 (Windows x64)