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

Module not found when packaged using Electron Forge #356

Closed
ImPhantom opened this issue Jan 4, 2022 · 4 comments
Closed

Module not found when packaged using Electron Forge #356

ImPhantom opened this issue Jan 4, 2022 · 4 comments

Comments

@ImPhantom
Copy link

ImPhantom commented Jan 4, 2022

I'm currently trying to migrate one of my projects from RobotJS to an actively maintained alternative, and found this. But I'm having trouble including this module in the packaged version of my Electron application. Everything works fine when just running the app via 'electron-forge start', but the binaries/installers produced by the package/make scripts don't seem to include NutJS at all.
Resulting in Cannot find module '@nut-tree/libnut-win32'

I'm using the Webpack Template for Electron Forge. Which seems to handle native modules quite well. But I'm not sure whats happening here...

I'm fairly sure this isn't an issue with the actual library itself, but more a webpack/electron configuration issue that I'm just hoping someone might have some insight on. Apologies if this isn't the best place to ask this question, but I figured its better than not asking at all and pulling my hair out...

Project Source

@s1hofmann
Copy link
Member

Hi @ImPhantom 👋

I had a quick look on this issue and noticed that the @vercel/webpack-asset-relocator-loader plugin seems to be tripping over the dynamic require

require(`@nut-tree/libnut-${process.platform}`);

used in @nut-tree/libnut.
I pushed an update, could you please check the latest snapshot of nut.js?

npm i @nut-tree/nut-js@next

Thanks for reaching out!

Best regards

Simon

@ImPhantom
Copy link
Author

That seems to have solved the problem completely. Thank you for the help, and for such a quick response!

ImPhantom added a commit to ImPhantom/Clickr that referenced this issue Jan 7, 2022
@GaurangTandon
Copy link

I just logged an issue in the electron-forge repo when using their webpack template on Windows. I think the issue is related to @vercel/webpack-asset-relocator-loader, hence I am linking it here: electron/forge#2901

I believe since you've already patched this, it should not be an issue from this side. But if you think it is from this side, I'll be happy to make a PR/help find the issue.

@s1hofmann
Copy link
Member

@GaurangTandon Thanks for the heads up! 👍

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

3 participants