electron / forge

:electron: A complete tool for building and publishing Electron applications
https://electronforge.io
MIT License
6.51k stars 520 forks source link

Cannot find native module in packaged app #3145

Open johannesgiani opened 1 year ago

johannesgiani commented 1 year ago

Pre-flight checklist

Electron Forge version

6.0.4

Electron version

v22.0.2

Operating system

macOS 11.3

Last known working Electron Forge version

No response

Expected behavior

Native module should be loaded inside renderer in development and in the packaged app.

Actual behavior

During development native modules work just fine but in the packaged app it cannot find the native module:

Uncaught Error: Cannot find module '/native_modules/build/Release/hello_world.node'

Steps to reproduce

  1. Create an electron-forge app with typescript + webpack template
  2. Install a native module such as native-hello-world
  3. Adjust forge.config.ts and index.ts to create a browser window with node integration enabled
  4. start the app with npm start. It should work
  5. package the app with npm run package and open it: doesn't work

Here is also a link to a repository with the code following the steps above.

Additional information

No response

elya5 commented 5 days ago

Did you get it to work in the end?