isElectronApp is true but remote is null
See original GitHub issueI tried the workarounds here: https://github.com/ThorstenHans/ngx-electron/issues/32
With:
win = new BrowserWindow({ width: 950, height: 555, backgroundColor: "#ffffff",
acceptFirstMouse: true,
webPreferences: {
nodeIntegration: true,
nodeIntegrationInWorker: true,
backgroundThrottling: false
}
});
Somehow nodeIntegration: true
seems to go ignored for me, I’m trying to use the remote module to require fs
but remote keeps coming back as null. Spent all day trying all different kinds of workarounds, but nothing worked. I have "@angular-builders/custom-webpack": "^9.2.0"
and "electron-builder": "^22.7.0"
:
const webpack = require('webpack')
module.exports = {
node: {
crypto: false,
path: true,
os: true,
stream: true,
buffer: false
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
})
]
}
I also tried adding:
target: "node-webkit",
It compiles and packages the app but throws require is not defined
before the app gets loaded, I guess this only worked in an older version of webpack.
angular.json has:
"builder": "@angular-builders/custom-webpack:browser",
If I try to require('electron').remote
or window.require('electron').remote
in the console after the unmodified app has loaded (no ngx-electron inside), then I just get require is not defined as well.
Issue Analytics
- State:
- Created 3 years ago
- Comments:18
Its because of the new security options they add as electron gets updated more, my current webPreferences for my main window I know you need on electron 12 are
Try:
Among other things that’s one thing I changed, you can also keep your eyes on https://github.com/QuestNetwork/quest-messenger-js - I still have a little libp2p pubsub issue (ipfs/js-ipfs issues/3249), but once that’s solved and the demo works, I’ll commit it and it has remote working now (using it to require ‘fs’ so that I can store config, message history, etc)