Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug?]: electron-builder couldn't be built successfully #4804

Closed
1 task
ouliuquan opened this issue Aug 31, 2022 · 7 comments
Closed
1 task

[Bug?]: electron-builder couldn't be built successfully #4804

ouliuquan opened this issue Aug 31, 2022 · 7 comments
Labels
bug Something isn't working

Comments

@ouliuquan
Copy link

ouliuquan commented Aug 31, 2022

Self-service

  • I'd be willing to implement a fix

Describe the bug

electron-builder can be build by npm(now), and the old yarn2 (last year), but when I use the new yarn3, it can't be built the deps.

I use the Electron and change the default builder package to electron-builder, it will be error when using yarn3:
https://github.com/electron/electron-quick-start

add those script in package.json:
"make": "electron-builder",
"postinstall": "electron-builder install-app-deps",
"postuninstall": "electron-builder install-app-deps"

and add "electron-builder": "latest" to devDependencies,
then, use the yarn to download the deps, it will error.

S D:\Project\electron\electron-quick-start> yarn                             
➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed in 2s 123ms
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0007: │ electron-quick-start@workspace:. must be built because it never has been before or the last one failed
➤ YN0009: │ electron-quick-start@workspace:. couldn't be built successfully (exit code 1, logs can be found here: C:\Users\ROADRU~1\AppData\Local\Temp\xfs-c0d01bb5\build.log)
➤ YN0000: └ Completed in 0s 659ms
➤ YN0000: Failed with errors in 2s 999ms

ps: If you want to test all, you can run yarn make to build exe file.

To reproduce

{
  "name": "electron-quick-start",
  "version": "1.0.0",
  "description": "A minimal Electron application",
  "main": "main.js",
  "scripts": {
    "start": "electron .",
    "make": "electron-builder",
    "postinstall": "electron-builder install-app-deps",
    "postuninstall": "electron-builder install-app-deps"
  },
  "repository": "https://github.com/electron/electron-quick-start",
  "keywords": [
    "Electron",
    "quick",
    "start",
    "tutorial",
    "demo"
  ],
  "author": "GitHub",
  "license": "CC0-1.0",
  "devDependencies": {
    "electron": "^20.1.0",
    "electron-builder": "latest"
  }
}

Environment

System:
    OS: Windows 10 10.0.22000
    CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700H
  Binaries:
    Node: 18.7.0 - C:\Users\ROADRU~1\AppData\Local\Temp\xfs-4c319603\node.CMD
    Yarn: 3.2.3 - C:\Users\ROADRU~1\AppData\Local\Temp\xfs-4c319603\yarn.CMD
    npm: 8.15.0 - D:\Program Files\nodejs\npm.CMD

Additional context

No response

@ouliuquan ouliuquan added the bug Something isn't working label Aug 31, 2022
@RDIL
Copy link
Member

RDIL commented Sep 1, 2022

Can you please provide the logs?

@ouliuquan
Copy link
Author

ouliuquan commented Sep 1, 2022

Thanks RDIL, I had run yarn again, still have problem, @RDIL

PS D:\Project\electron\electron-quick-start> yarn
➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed in 1s 145ms
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0007: │ electron-quick-start@workspace:. must be built because it never has been before or the last one failed
➤ YN0009: │ electron-quick-start@workspace:. couldn't be built successfully (exit code 1, logs can be found here: C:\Users\ROADRU~1\AppData\Local\Temp\xfs-a88f95f7\build.log)
➤ YN0000: └ Completed in 0s 606ms
➤ YN0000: Failed with errors in 1s 946ms

Here is the log file build.log:

# This file contains the result of Yarn building a package (electron-quick-start@workspace:.)
# Script name: postinstall

  • electron-builder  version=23.5.0
  ⨯ Cannot compute electron version from installed node modules - none of the possible electron modules are installed and version ("^20.1.1") is not fixed in project.
See https://github.com/electron-userland/electron-builder/issues/3984#issuecomment-504968246

And I have look at electron-userland/electron-builder#3984 (comment), still can't know how to fix this, and help others avoid this problem.

I have write the same issue in electron-builder, hope we can fix the problem. electron-userland/electron-builder#7106

@RDIL
Copy link
Member

RDIL commented Sep 1, 2022

I don't think that you can use PnP with Electron, you may need to enable the node modules linker.

@ouliuquan
Copy link
Author

Thanks for help, I am graceful. I have fix this problem and will write to electron-builder's readme.

This is because of yarn 3 use PnP by default, but electron-builder still need node-modules.
So just add .yarnrc.yaml file in folder, write this:

nodeLinker: "node-modules"

will declare to use node-modules instead of PnP.

@vintage88
Copy link

So just add .yarnrc.yaml file in folder, write this:

nodeLinker: "node-modules"

will declare to use node-modules instead of PnP.

may I know which folder is the folder you are referring to?

@ouliuquan
Copy link
Author

@vintage88 I list project folder here:

.
├── .yarnrc.yaml
├── package.json
├── index.js
├── node_modules/

@dperetti
Copy link

dperetti commented Mar 4, 2023

Well, the real fix would be to make electron-builder compatible with PnP...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants