bun icon indicating copy to clipboard operation
bun copied to clipboard

bug: Electron failed to install correctly

Open MidKnightXI opened this issue 1 year ago • 1 comments

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"
  }
}

MidKnightXI avatar Dec 08 '22 06:12 MidKnightXI

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.

Electroid avatar Dec 08 '22 17:12 Electroid

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)

Gabriel-Alves-Cunha avatar Mar 06 '23 00:03 Gabriel-Alves-Cunha

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 

image

bun install

image

and I make a test adding a path.txt file but does't works because of is missing dist folder image

and anothers folders maybe adding this files on bun install works

Warmachine13 avatar Jun 09 '23 02:06 Warmachine13

Still happening on v0.7.3 CleanShot 2023-08-14 at 03 05 51@2x

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 CleanShot 2023-08-14 at 03 09 39@2x

jonluca avatar Aug 14 '23 01:08 jonluca

What does

bun --bun run dev

result in?

birkskyum avatar Aug 14 '23 06:08 birkskyum

CleanShot 2023-08-14 at 10 56 51@2x

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

jonluca avatar Aug 14 '23 08:08 jonluca

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

birkskyum avatar Aug 31 '23 15:08 birkskyum

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

acnebs avatar Sep 14 '23 04:09 acnebs

Duplicate of #4959

Electroid avatar Oct 24 '23 22:10 Electroid

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.

Jarred-Sumner avatar Dec 12 '23 06:12 Jarred-Sumner

Thank you and keep up with the hard work :)

MidKnightXI avatar Dec 12 '23 09:12 MidKnightXI

Is now fixed ! @Jarred-Sumner

andirsun avatar Dec 14 '23 01:12 andirsun