question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Electron-packager Not allowed to load local resource

See original GitHub issue

When 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:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
maleptcommented, Oct 10, 2016

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.

0reactions
rkpatel33commented, Aug 27, 2017

settings.js exported a dict that looks like the below. I used root: path.resolve('./') with the single dot even though this file is one dir deep bc when running from npm 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 to root: path.join(__dirname, '../'), everything worked fine.

image

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:

require(path.join(global.PROJECT_ROOT + '/' + rootPath))

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found