Tag Archives: electron error

[Solved] Electron Error: ReferenceError: require is not defined

Error reported by electron: referenceerror: require is not defined

This error is suddenly reported. Many people on the Internet say that nodeintegration: true should be set, but it doesn’t work.
until I see a comment on stackoverflow:
all you need to do is add contextisolation: false after nodeintegration: true in the webpreferences object,
try it and it’s OK, This means adding contextisolation: false after nodeintegration: true

[Solved] Electron Error: Error: Electron failed to install correctly, please delete node_modules/electron and try

When building an electron Vue project on win10, an error is reported using the NPM install command
report errors:

Error: Electron failed to install correctly, please delete node_modules/electron and try installing again

Solution::

Enter the node_modules/electron directory in the project from the command line and run the node install.js command

Solution to electron error “cannot find module app”

Solution:

The original code looks like this:

var app = require('app');
var BrowserWindow = require('browser-window');

To be amended as follows:

const electron = require('electron');
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;

Cause of error: the version of electron used is too new, and this API has been removed in electron v1.0.0. “Cannot find module…” appears again Basically, it’s all because the module is directly introduced by require. If there are errors in the introduction of other modules, you have to check the API now. Not all of them are “const Balabala”= electron.balabala ”For example, the introduction of IPC is:

const ipc = electron.ipcMain;