Hi, it's Takuya. I'm making a Markdown note-taking app called Inkdrop with Electron.
I upgraded Electron from 7 to 12 in this project, and here are some troubleshootings.
Upgrading packages
npm i electron@12.0.0 electron-rebuild@latest
In case node-abi
is not the latest, upgrade it:
npm update node-abi --depth 2
require()
is not defined
There is the following breaking change:
- Changed the default value of
contextIsolation
totrue
. #27949
It overrides nodeIntegration
option. So, you have to specify options like so:
webPreferences: {
contextIsolation: false,
enableRemoteModule: true,
nodeIntegration: true,
nodeIntegrationInWorker: true,
webviewTag: true
}
remote
module deprecation
There is another breaking change:
- Deprecated the
remote
module. It is replaced by@electron/remote
. #25293
You should fix like so:
// Deprecated in Electron 12:
const { BrowserWindow } = require('electron').remote
// Replace with:
const { BrowserWindow } = require('@electron/remote')
// In the main process:
require('@electron/remote/main').initialize()
Failed to serialize arguments
My app calls a function of the main process.
It passed a BrowserWindow
object as its parameter and that causes the error: Failed to serialize arguments
.
I replaced that code to use browser window ID instead.
Ubuntu gets blank screen on VM
Apparently, it only happens on Paralells VM.
You can run the app by appending --disable-gpu
option like so:
npm start -- --disable-gpu
Hope that helps!
Top comments (4)
Hello, thanks for sharing this. I had a question, do v8 snapshots work for you? I tried with Electron 9 and it's working fine, but on Electron 11 or 12 (to support M1 macs), the global variable
snapshotResult
is not defined.I have the same issue :( Did you report that to the community?
Reported at github.com/electron/mksnapshot/iss..., but I saw that you got here too. No response from the maintainer since about a month :/
Hope they'll give us a hint :)