mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-04 05:34:51 +00:00
require() in webpage doesn't use proper relative paths #276
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @The-MAZZTer on GitHub (Feb 10, 2019).
Originally assigned to: @GregorBiswanger on GitHub.
I am using electornize start to start my project from my project folder. I am using Electron.NET 0.0.11 under .NET Core 2.1.6 (I was going to use 2.2 but I got some warnings suggesting Electron.NET wasn't yet compatible).
I get "cannot load module" even though I can confirm the module is at the proper location.
For example for the url http://localhost:8001/ I have an index.html with the JavaScript: require("./scripts/main");
Trying to access
httpshttp://localhost:8001/scripts/main.js manually from a browser properly returns the JavaScript file I want it to load.I pulled in these files from a normal Electron project where they worked.
I did some JS debugging in both Electron and Electron.NET. There is a parent value passed in which appears to contain the path of the script that is executing, which allows require() to resolve relative paths.
In Electron.NET, this value is INCORRECTLY set as "<ProjectDir>\obj\Host\node_modules\electron\dist\resources\electron.asar\renderer\init.js". It appears this is the path the webpage thinks it is at in the Module class which is responsible for creating a proper require command and tracking its current path and a bunch of other stuff. I am seeing this value propagate from Module.prototype._compile.
@JimmyTheJ commented on GitHub (Feb 11, 2019):
You can't use HTTPS with electronNET.
@The-MAZZTer commented on GitHub (Feb 13, 2019):
Sorry, I meant HTTP. I am not using HTTPS in Electron.NET.
@GregorBiswanger commented on GitHub (May 16, 2019):
Please include the following base href in your index file:
<base href="./">Note that usually the wwwroot directory is directly mapped and your relevant files are there.