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

App threw an error during load When I use electron-forge create a templates=webpack electron project #28

Closed
focus-sc opened this issue Jan 10, 2023 · 5 comments

Comments

@focus-sc
Copy link

It's right run when I use electron-forge create a normal electron project. But if I use templates=webpack or templates=webpack-typescript to create an electron project, it's will be abnormal when I use yarn start to run the project. This screenshot show the error: Error: No native build was found for platform=darwin arch=x64 runtime=electron abi=110 uv=1 libc=glibc node=16.17.1 electron=22.0.0 webpack=true;
image

@SnosMe
Copy link
Owner

SnosMe commented Jan 10, 2023

@SnosMe SnosMe closed this as not planned Won't fix, can't repro, duplicate, stale Jan 10, 2023
@marcelblum
Copy link

I ran into similar issues especially when trying to build a universal mac app, I had to disable auto rebuild via rebuildConfig: {onlyModules: []} in the forge config, and rename the uiohook-napi binary very platform-specifically to darwin-arm64/darwin.arm64.electron.110.napi.node. I think it's a problem with prebuildify trying to be a little too smart while infering filenames/versions. Hope this helps.

@focus-sc
Copy link
Author

Look for potential solution in prebuild/node-gyp-build#22

I'm using esbuild and have no issues https://github.com/SnosMe/awakened-poe-trade/blob/d1e30bfe754f2fbdc44e3ea12a6278e4d61cb242/main/build/script.cjs#L27

Thank you. It's useful when I add externals like ['electron', 'uiohook-napi', 'electron-overlay-window'] in webpack.renderer.config.ts

@focus-sc
Copy link
Author

I have a new problem. I used externals: ['uiohook-napi'] in webpack.config.ts, It's useful to run a develop project. But It's got error when I used electron-forge make to build a production project. what should I do to config the project? Thank you very much.
_Uncaught Exception:
Error: Cannot find module 'uiohook-napi'
Require stack:

  • /Applications/Bytelingo.app/Contents/
    Resources/app/.webpack/main/index.js_

image

@prevzzy
Copy link

prevzzy commented Feb 22, 2024

I ran into this issue using electron-overlay-window.

As in @focus-sc's case, adding externals: ['electron-overlay-window'] to my webpack config indeed did help, but only for the development process. When trying to build the app, using electron-forge make, I always ended up with "Cannot find module "electron-overlay-window"" error on application launch.

What helped me was using @timfish/forge-externals-plugin and adding the following to forge.config.js:

plugins: [
    ...,
    new ForgeExternalsPlugin({
      externals: ['electron-overlay-window'],
    })
  ],

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

No branches or pull requests

4 participants