Cannot find native module in packaged app
- Dominant language
- TypeScript
- Stars
- 7.1k
- Forks
- 641
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 30
Description
### Pre-flight checklist
- [X] I have read the [contribution documentation](https://github.com/electron/forge/blob/main/CONTRIBUTING.md) for this project.
- [X] I agree to follow the [code of conduct](https://github.com/electron/electron/blob/main/CODE_OF_CONDUCT.md) that this project uses.
- [X] I have searched the issue tracker for a bug that matches the one I want to file, without success.
### 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](https://github.com/johannesgiani/electron-native-module-renderer) with the code following the steps above.
### Additional information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.