Skip to content
New issue

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

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

Already on GitHub? # to your account

yarn 3.2.3 not working in electron-builder install #7106

Closed
ouliuquan opened this issue Sep 1, 2022 · 1 comment
Closed

yarn 3.2.3 not working in electron-builder install #7106

ouliuquan opened this issue Sep 1, 2022 · 1 comment

Comments

@ouliuquan
Copy link
Contributor

  • Electron-Builder Version: 23.5.0
  • Node Version: v18.7.0 system, project may be 16.15.0 for Electron
  • Electron Version:20.1.1
  • Electron Type (current, beta, nightly):current
  • Target: x86_64

I have write the same problem in yarn issue, but I still can confirm that is yarn 3.2.3 's problem.
yarnpkg/berry#4804
So I am here ask for some help.

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.


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 #3984 (comment), still can't know how to fix this, and help others avoid this problem.

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.1",
    "electron-builder": "^23.5.0"
  }
}

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

Other way

I had the to change devDependencies to "electron": "20.1.1",(remove the ^), but this will make the system crate a lot of node.exe process, and will use all the memory. So, in this issue way can not fix the problem. #3984 (comment)

@ouliuquan
Copy link
Contributor Author

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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant