Closed DRocksCoding closed 3 years ago
electron 10 was released recently, and this is now throwing!
Uncaught TypeError: Cannot read property 'app' of undefined
at Object.<anonymous> (.../Lax/node_modules/electron-is-dev/index.js:4)
at Object.<anonymous> (.../Lax/node_modules/electron-is-dev/index.js:11)
at Module._compile (internal/modules/cjs/loader.js:1145)
at Module._compile (.../Lax/node_modules/pirates/lib/index.js:99)
at Module._extensions..js (internal/modules/cjs/loader.js:1166)
at Object.newLoader [as .js] (.../Lax/node_modules/pirates/lib/index.js:104)
at Module.load (internal/modules/cjs/loader.js:981)
at Module._load (internal/modules/cjs/loader.js:881)
at Function.Module._load (electron/js2c/asar.js:769)
at Module.require (internal/modules/cjs/loader.js:1023)
which links through to here:
const app = electron.app || electron.remote.app;
^
hopefully this gets fixed and bubbles up to electron-util
Getting rid of the remote usage would mean this could only be used in main process modules ( theres not alternative for app.isPackaged ).
The remote module is not being depreciated ( not notice in docs, nor any warnings in Electron 10.1.1 ) so setting enableRemoteModule:true in your web preferences is the solution.
same here I jsut posted that in electron-context-menu:
https://github.com/sindresorhus/electron-context-menu/issues/117#issue-690324541
remote object is deprecated and will be completely removed in Electron 14.
PS: what i did was the following, though it is not as elegant as using this package:
const isDev = !electron.app.isPackaged
new BrowserWindow({ webPreferences: {additionalArguments: [isDev ? 'ELECTRON_IS_DEV' : 'ELECTRON_IS_PACKAGED'] ...
const isDev = process.argv.includes('ELECTRON_IS_DEV');
In Electron V10 enableRemoteModule is false by default.
All you need to do is set it to true:
const w = new BrowserWindow({
webPreferences: {
enableRemoteModule: true
}
})
To fix this, you need to create a preload.js file and expose the entire electron object with contextBridge
. Not an elegant way to do it tho.
In a browser window without enableRemoteModule:true, this line warns about the usage of deprecated remote module with electron 9.1.0.
Would it be a good thing to get rid of remote usage?