Using Electron Forge with Bun is currently not straightforward due to compatibility issues. Electron Forge primarily relies on Node.js and npm for its operations, and Bun does not fully support all the features required by Electron Forge.
Key Points
1. Compatibility Issues: Users have reported that when trying to use Electron Forge with Bun, they encounter errors related to npm compatibility. For instance, Bun's versioning does not align with the expected npm versions required by Electron Forge[1].
2. Recommended Setup: The most reliable approach is to install both Node.js and Bun, but avoid mapping npm commands to Bun. This is because many tools in the Electron ecosystem expect npm to be present and functioning correctly. Using Bun as a drop-in replacement for npm can lead to various issues[1].
3. Alternative Approaches: If you want to experiment with Bun, consider using it for parts of your application that do not require Electron Forge's full functionality. However, for packaging and building your Electron app, sticking with Node.js and npm is advisable until Bun matures further and gains broader support within the Electron community[7].
Conclusion
While you can technically use Bun alongside Node.js, for effective development with Electron Forge, it's best to rely on Node.js and npm exclusively for now. If you are keen on using Bun, keep an eye on future updates from both the Electron and Bun teams regarding compatibility improvements.
Citations:[1] https://stackoverflow.com/questions/77295981/how-run-electron-js-with-bun
[2] https://www.electronforge.io/import-existing-project
[3] https://www.youtube.com/watch?v=8e4Kg8trNGo
[4] https://www.electronforge.io
[5] https://www.electronjs.org/docs/latest/tutorial/tutorial-packaging
[6] https://stackoverflow.com/questions/tagged/electron-forge?page=3&tab=newest
[7] https://github.com/electron/electron/issues/34876
[8] https://github.com/lovell/sharp/issues/3887