Reputation: 3901
I'm currently unable to load Electron modules in Javascript files outside of the main.js file.
I'm trying to use:
const electron = require('electron');
const ipcRenderer = electron.ipcRenderer;
in a file called settings.js.
I have the correct NPM modules installed (eletron-prebuilt).
The settings page is loaded in a webview like so:
<webview id="settings" src="./settings.html"></webview>
and the settings.js included like:
<script type='text/javascript' src='./resources/js/settings.js'></script>
Running out of ideas here, but I wonder if it's some kind of scoping issue?
Many thanks.
Upvotes: 2
Views: 5469
Reputation: 32127
You're loading it in a webview, which doesn't support nodeintegration by default.
Add the nodeintegration
attribute to your webivew.
<webview id="settings" src="./settings.html" nodeintegration></webview>
Upvotes: 4