Brendan Ryan
Brendan Ryan

Reputation: 3

Updating Electron app and getting error that Electron could not be found

Ok, so I'm trying to update a two year old Electron app to function. I needed to change out the syntax and remove window.require() and replace it with CreateBrowserWindow in order to get the app to render in a new window rather than in the browser at localhost:3000. While npm start creates a new window I keep getting a blank screen and the warning Electron could not be found. No hard resets for you! I am able to get into the createWindow function but the app is starting without recognizing electron. Not sure how to go about making this work. Haven't been able to find anything using GoogleFu. Below is the code at the start of electron.js in my public folder (I've tried moving it out of public to the root folder but it makes no difference):

const { app, BrowserWindow, Menu, dialog } = require('electron'); 
const createWindow = () => { 
     const win = new BrowserWindow({ 
          width: 800, height: 600, webPreferences: { 
          nodeIntegration: true, contextIsolation: false } 
     }) 
     console.log('error') 
     win.loadFile('./index.html'); 
}; 
app.whenReady().then(() => { createWindow() })

When I run it I get this output:

Electron could not be found. No hard resets for you! then line break error

The problem is occurring at the outset. How do I direct my app to find electron?

Upvotes: 0

Views: 946

Answers (1)

Juan Araneta
Juan Araneta

Reputation: 335

Have you tried removing

require('electron-reload')(_dirname)

so you don't run electro-reload on development environment?

Upvotes: 0

Related Questions