-
Notifications
You must be signed in to change notification settings - Fork 15k
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
Setting base directory to resolve relative requires #2414
Comments
Update: Using a local host instead of |
|
I have been testing by changing NODE_PATH, which fixes require statements like I guess there is no way of resolving this without a source transform like browserify? |
No, this is a limitation of Node.js, the whole module system only works on filesystem. |
|
After debugging for one week, I found this and it quickly resolved my issue. In my dev mode, I was directly loading localhost in electron main process window and was trying to reference some externally exposed webpack dependencies that was throwing error of cannot find module. Though I was using html-webpack-plugin that creates a hidden html file from template in memory and injects all webpack bundles into it. So I had no idea how to load that in memory html file with file:// protocol in electron main window. Then I found html-webpack-harddisk-plugin that fixed everything. Thank you everyone for giving me the hint. |
I'm having the same problem: My index.html (in root /) references ./js/main.js (in a script tag) which does |
This is similar to #1971, but I'm looking to fix relative requires as well.
Using the following with
node-integration
, everything is working fine:However, when
index.html
and the clientindex.js
is served on localhost, the require paths are not getting resolved correctly. Is there a way to set the path for relative requires?The issue can be reproduced here:
https://github.com/mattdesl/test-electron-require
My main reason for using localhost is for a smoother development experience: I can stream transpiled source (i.e. webpack, browserify, babel) to the response, rather than wiring up a build step with static files.
The text was updated successfully, but these errors were encountered: