-
Notifications
You must be signed in to change notification settings - Fork 150
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
Electron 29 beta Cannot Find Packages when using ESM #401
Comments
我前几天也遇到过,当时以为是external的问题,结果 |
I still reproduce this with latest The suggested solutions did not work for me:
Error is there when running How did you solve this? |
try 29.1.1 |
I got same error running after clean install of Electron 29.1.1. I run Error:
I realize that I'm only getting this error if I import electron-log from /main alias such as: import log from "electron-log/main"; Importing only from import log from "electron-log"; However importing it as I'm unsure if this has anything to do with |
electron-vite only builds the code and does not affect the runtime. This problem may be a problem with electron-builder or electron. There is no problem with subpath modules under |
Don't externalize the module yet and let electron-vite bundle it. This is also a way to avoid this problem. |
The suggested workaround worked for me. Thank you for the capability, sticking around and supporting the community @alex8088 ❤️. This fixes it: externalizeDepsPlugin({
exclude: [ electron-log' ]
})] |
This commit bumps Electron and related dependencies to their latest versions to leverage native ESM support. It adjusts build configuration to use native ESM support instead of relying on CommonJS bundling. Key changes: - Bump Electron to latest v29. Electron v28 ships with native ESM/ECMAScript modules support. Details on Electron ESM support: - electron/electron#21457 - electron/electron#37535 - Bump `electron-builder` to latest v24.13. `electron-builder` is used to package and publish the application. It supports ESM since 24.10. Details on `electron-builder` ESM support: - electron-userland/electron-builder#7936 - electron-userland/electron-builder#7935 - Bump `electron-log` to latest v5.1. `electron-log` supports ESM since version 5.0.4. Details on `electron-log` ESM support: - megahertz/electron-log#390. - Change `electron-vite` configuration to bundle as ESM instead of CommonJS to leverage Electron's native ESM support. Other supporting changes: - Add type hint for electron-builder configuration file. - Update import statements for `electron-updater` as it still is a CommonJS module and does not support ESM. Details: - electron-userland/electron-builder#7976 - Improve `electron-builder` configuration file to dynamically locate main entry files, supporting various JavaScript file extensions (`.js`, `.mjs` and `.cjs`) to facilitate easier future changes. - Change comment about Electron process-specific module alias registration. This issue has been fixed in `electron-vite`, but subpath module imports for Electron still do not work when building tests (`npm run test:unit`). Details: - alex8088/electron-vite#372 - Add `electron-log` in bundling process instead of externalizing to workaround Electron ESM loader issues with subpath imports (inability to do `electron-log/main`). Details: - alex8088/electron-vite#401 - electron/electron#41241 - Improve desktop runtime error checks' assertion message for better clarity.
I was able to get around this with |
Describe the bug
Reproduce
You can use this repo to reproduce (it just followed the steps below): https://github.com/johnlindquist/electron-29
npm create @quick-start/electron
esm
guideelectron-log
and use it in main/index.ts: https://github.com/johnlindquist/electron-29/blob/main/src/main/index.ts#L5npm i electron@beta
(29.0.0-beta.5 as of today)npm run dev
Works fine
npm run build:mac
./dist/mac-arm64/foo.app
Your run into a
Cannot find package
, "electron-log" error.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
The text was updated successfully, but these errors were encountered: