Electron-packager Not allowed to load local resource
See original GitHub issueWhen launching my app with electron there is no problems to do that:
mainWindow.loadURL(
${__dirname}/…/build/index.html)
But when packaging it with electron-packager and launching the .exe file I get this error in the console:
Not allowed to load local resource: file:///***/index.html (pointing to my index.html)
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:5 (3 by maintainers)
Top Results From Across the Web
electron-packager Not allowed to load local resource
There is a lot of detail missing from this request. I would always use path.resolve to access your local files rather than the...
Read more >Not allowed to load local resource · Issue #25884 - GitHub
I have searched the issue tracker for an issue that matches the one I want to file, without success. Issue Details. Electron Version:...
Read more >'Not allowed to load local resource' error when package the app
I think you need to use a path relative to the src/working folder. The transpiler probably doesn't know how to handle to absolute...
Read more >Electron Error: Not allowed to load local resource | Chris Green
Not allowed to load local resource. I was certain I'd typed the line to load the URL just like the tutorial suggested.
Read more >Built Electron app shows nothing: "Not allowed to load local ...
Though opening .exe built file showed nothing. I saw an error in the console: Not allowed to load local resource: ...\resources\app.asar/index.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Since the original issue reporter has not responded to the request for additional information in about two weeks, I’m going to assume that they either found the answer in another manner or decided not to pursue this issue. If I’m incorrect, they can respond with answers to the questions posed, and I’ll reopen.
settings.js
exported a dict that looks like the below. I usedroot: path.resolve('./')
with the single dot even though this file is one dir deep bc when running fromnpm run
it seemed to resolve to where the npm command was run from, i.e. project root dir. I guess this was causing issues in the build bc when I changed it toroot: path.join(__dirname, '../')
, everything worked fine.More generally, I was wondering if there is a solution/setup where I can source everything from paths relative to the project root dir (like require statements as well as path.join()'s) so that you don’t have to worry about keeping paths up to date if you just move a file to a diff directory. If I set up a global var and use that in a path join in a require statement like this:
It breaks my Eslint and VS Code IntelliSense, I guess expectedly. In a Webpack setting this is possible but just not sure if it is in an Electron project setting.
Thx.