Skip to content

[Bug]: Electron 29. "Cannot Find Packages" when targeting ESM #41241

Closed

Description

@johnlindquist

Preflight Checklist

Electron Version

29.0.0-beta.5

What operating system are you using?

macOS

Operating System Version

Sonoma 14.3

What arch are you using?

arm64 (including Apple Silicon)

Last Known Working Electron version

28

Expected Behavior

Packages should be found

Actual Behavior

Describe the bug

Reproduce

You can use this repo to reproduce (it just followed the steps below): https://github.com/johnlindquist/electron-29

npm run dev

Works fine

npm run build:mac

  • Successfully builds
  • open ./dist/mac-arm64/foo.app

Your run into a Cannot find package, "electron-log" error.

Uncaught Exception:
Error: Cannot find package '/Users/johnlindquist/dev/electron-29/dist/mac-arm64/electron-29.app/Contents/Resources/app.asar/node_modules/electron-log/package.json' imported from /Users/johnlindquist/dev/electron-29/dist/mac-arm64/electron-29.app/Contents/Resources/app.asar/out/main/index.mjs
Did you mean to import electron-log/src/index.js?
at legacyMainResolve (node:internal/modules/esm/resolve:189:26)
at packageResolve (node:internal/modules/esm/resolve:783:14)
at moduleResolve (node:internal/modules/esm/resolve:845:20)
at defaultResolve (node:internal/modules/esm/resolve:1050:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:383:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:352:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:228:38)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:85:39)
at link (node:internal/modules/esm/module_job:84:36)

CleanShot 2024-02-03 at 09 41 14

Fix

Downgrade to Electron 28, build works fine again.

Electron-Vite Version

2.0.0

Electron Version

29.0.0-beta.5

Vite Version

5.0.11

Validations

Testcase Gist URL

No response

Additional Information

I originally reported this here: alex8088/electron-vite#401

But this they told me this is an Electron issue

Activity

  1. codebytere commented on Feb 5, 2024

    @codebytere
    Member

    hmm - i cloned your repo, installed deps, and ran npm run build:mac and I get:

    electron-29 on git:main ❯ npm run build:mac                                   6:01PM
    
    > [email protected] build:mac
    > electron-vite build && electron-builder --mac --config
    
    vite v5.0.12 building SSR bundle for production...
    ✓ 2 modules transformed.
    out/main/index.mjs  1.71 kB
    ✓ built in 37ms
    vite v5.0.12 building SSR bundle for production...
    ✓ 1 modules transformed.
    out/preload/index.mjs  0.38 kB
    ✓ built in 5ms
    vite v5.0.12 building for production...
    ✓ 32 modules transformed.
    ../../out/renderer/index.html                   0.52 kB
    ../../out/renderer/assets/icons-p39i8CQ2.svg    9.06 kB
    ../../out/renderer/assets/index-ME2HaU7H.css    2.88 kB
    ../../out/renderer/assets/index-ZHdq04n_.js   228.87 kB
    ✓ built in 388ms
      • electron-builder  version=24.9.1 os=23.2.0
      • loaded configuration  file=/Users/codebytere/Developer/repros/electron-29/electron-builder.yml
      • writing effective config  file=dist/builder-effective-config.yaml
      • skipped dependencies rebuild  reason=npmRebuild is set to false
      • packaging       platform=darwin arch=arm64 electron=29.0.0-beta.5 appOutDir=dist/mac-arm64
      • downloading     url=https://github.com/electron/electron/releases/download/v29.0.0-beta.5/electron-v29.0.0-beta.5-darwin-arm64.zip size=95 MB parts=8
      • downloaded      url=https://github.com/electron/electron/releases/download/v29.0.0-beta.5/electron-v29.0.0-beta.5-darwin-arm64.zip duration=27.574s
      • skipped macOS application code signing  reason=cannot find valid "Developer ID Application" identity or custom non-Apple code signing certificate, it could cause some undefined behaviour, e.g. macOS localized description not visible, see https://electron.build/code-signing allIdentities=     0 identities found
                                                    Valid identities only
         0 valid identities found
      • building        target=macOS zip arch=arm64 file=dist/electron-29-1.0.0-arm64-mac.zip
      • building        target=DMG arch=arm64 file=dist/electron-29-1.0.0.dmg
      • Detected arm64 process, HFS+ is unavailable. Creating dmg with APFS - supports Mac OSX 10.12+
      • building block map  blockMapFile=dist/electron-29-1.0.0.dmg.blockmap
      • building block map  blockMapFile=dist/electron-29-1.0.0-arm64-mac.zip.blockmap
    

    Are there any steps I might have missed?

  2. added
    blocked/need-info ❌
    on Feb 5, 2024
  3. johnlindquist commented on Feb 5, 2024

    @johnlindquist
    Author

    @codebytere The error doesn't show until after you attempt to open the packaged app:

    CleanShot 2024-02-05 at 10 48 22

  4. codebytere commented on Feb 6, 2024

    @codebytere
    Member

    🤦🏻‍♀️ sorry, you're totally right. I see the issue and can repro it - this may be solved in #41209 but i can follow up and check.

  5. added
    status/confirmed
    has-repro-repo
    and removed
    blocked/need-info ❌
    on Feb 6, 2024
  6. johnlindquist commented on Feb 6, 2024

    @johnlindquist
    Author

    @codebytere awesome, thanks. Let me know if there's anything else I can do to help.

  7. johnlindquist commented on Feb 6, 2024

    @johnlindquist
    Author

    @codebytere I just tried on v29.0.0-beta.6 which says it has the original-fs fix, but I'm getting the same error.

  8. codebytere commented on Feb 7, 2024

    @codebytere
    Member

    Yep - you're right, i'm seeing that too. I'll investigate more within the next ~week!

  9. self-assigned this
    on Feb 7, 2024
  10. moved this to 👀 Unsorted Items in 29-x-yon Feb 14, 2024
  11. moved this from 👀 Unsorted Items to 🛑 Blocks Stable in 29-x-yon Feb 14, 2024
  12. codebytere commented on Feb 14, 2024

    @codebytere
    Member

    I think i've tracked this to nodejs/node#48325 via 9c94fd7 - looking a bit more

  13. codebytere commented on Feb 19, 2024

    @codebytere
    Member

    Closed by #41367

  14. undergroundwires commented on Mar 14, 2024

    @undergroundwires

    Thanks for the fix @codebytere, I can still reproduce this using latest electron (29.1.4), did this bug creep in again somehow?

  15. kylekirkby commented on Mar 14, 2024

    @kylekirkby

    Thanks for the fix @codebytere, I can still reproduce this using latest electron (29.1.4), did this bug creep in again somehow?

    Yh, we're seeing this too in 29.1.4

  16. undergroundwires commented on Mar 17, 2024

    @undergroundwires

    I found out that I only get this when I import it using /main alias such as:

    import log from "electron-log/main";

    Importing only from electron-log does not yield this error:

    import log from "electron-log";
  17. alex8088 commented on Mar 18, 2024

    @alex8088

    @codebytere Electron ESM loader cannot correctly resolve subpath modules.

  18. moved this from 🛑 Blocks Stable to 🛠️ Fixed for Next Release in 29-x-yon Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

29-x-yESMbug 🪲has-repro-repoplatform/macOSstatus/confirmed

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions