☆解決方法
- メインプロセス側のBrowserWindow作成時にnodeIntegrationをtrueにする
- レンダラーのhtmlで読み込むjsファイルはrequireを使う
★メインプロセス
app.on('ready', () => { mainWindow = new BrowserWindow({ webPreferences: { nodeIntegration: true } }); });
BrowserWindowの初期化時にはwebPreferencesのnodeIntegrationをtrueに設定。
★レンダラープロセス(html)
<script> require('./index.js') </script>
requireでjsファイルを読み込む
☆nodeIntegrationのデフォルト値はV5で変わったらしい
electronjs.org
ただ、ネットの情報を見る感じだと、過去にもnodeIntegrationのはコロコロ変わってるもよう