-
-
Notifications
You must be signed in to change notification settings - Fork 523
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
remote.require() is relative to electron-forge/lib/cli.js not package.main #365
Comments
Hmm... this definitely seems like a bug. When the app is packaged, then To reproduce run |
@gmaclennan Could you try applying the patch here electron-userland/electron-compile#274 to your local install of FWIW I always recommend using absolute paths for things like this, relative paths are just asking for trouble 😉 |
hi @MarshallOfSound thank you for looking into this. I get an error function (path) {
assert(path, 'missing path');
assert(typeof path === 'string', 'path must be a string');
return Module._load(path, this, /* isMain */ false);
} Using an absolute path would not work for the packaged app - it tries to load the module from outside the app bundle. Absolute paths would also break the app for other collaborators. |
@gmaclennan When I say absolute paths I mean resolve it yourself. I.e. Resolve all paths relative to a known points inside your app |
Hi @MarshallOfSound great stuff, this patch does fix things when running the app with Thanks for the clarification about absolute paths, I am used to using browserify and I forgot I can have variables in require pathnames in electron :) |
I think that's something we can fix on forges side by simply positioning that shim right next to your actual entry point file 👍 If I get time I'll try work on this some time next week |
This will be fixed in v6 because |
Please describe your issue:
According to the electron docs on
remote.require
:However, when running an app with
electron-forge start
thenremote.require
resolves relative tonode_modules/electron-forge/lib/cli.js
.This is mentioned in #48 (comment) but the issue is closed.
If this is expected/intended behavior then I suggest that this is documented somewhere, if it is unintended, then we need an open issue to fix it. Happy to update this issue to be either a documentation issue or a bug.
Please provide either a failing minimal testcase (with a link to the code) or detailed steps to
reproduce your problem. Using
electron-forge init
is a good starting point, if that is not thesource of your problem.
The repo below demonstrates this behavior with a minimal test case showing how the expected use of
remote.require
fails.https://github.com/gmaclennan/forge-remote-require-test
The text was updated successfully, but these errors were encountered: