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
problems with requiring modules with "win.loadURL(data:text/html;charset=utf-8,${html}
)"
#8425
Comments
I actually would wish that there would be an additional method, like:
Alternative - maybe i can open an http server on the fly and use it to serve a file on localhost - but i guess that would allow a web browser or a different app to listen to that port... Is there a way to provide HTML without creating a separate html file? |
I'm like 99% sure this is "expected" in a sense. Whenever you use If you somehow logged out For instance when testing with an Electron Prebuilt (the default app). # In the default app console
__dirname === "C:\Users\Samuel\.electron\electron-v1.4.2-win32-x64\resources\default_app.asar"
# In the "data/html" loaded window
__dirname === "C:\Users\Samuel\.electron\electron-v1.4.2-win32-x64\resources\electron.asar\renderer" The second path is not even inside the current application ASAR so the require search path will be completely different. I'm pretty sure this is the expected behavior as there is no other logical directory we can assign to this pseudo HTML file. |
Here is the code that makes Line 111 in d064325
As a temporary workaround I've set up module.paths and module.filename inside data:text/html template and require started working.
|
Yeah, pages using require from data URLs will probably need to set up the Closing this out since this the expected behavior, thanks @MarshallOfSound for the in-depth explanation 👍 |
FYI the original 'not working' version now works well as #9095 is merged. |
Expected behavior
My electron app should open and in the devtools i would be able to access
window.bel
Actual behavior
My electron app opens and in the devtools i see the error message:
Uncaught SyntaxError: Unexpected identifier
which i fixed by adding a semicolon which turned it into:
Uncaught Error: Cannot find module 'bel'
How to reproduce
I'm using the standard
electron-quick-start
The only line that is different between a working version of the code and the not working version is:
not working version
working version
The text was updated successfully, but these errors were encountered: