#app is undefined

20 messages · Page 1 of 1 (latest)

raven wagon
#

read somewhere that this might be caused due to an inproper installation of electron but i followed the steps on the introduction page so i dont see why that would be a problem?

#
const { app, BrowserWindow } = require('electron');
vivid vale
#

I think you need to give more info about your config if you want help

raven wagon
#

well I have no clue whats wrong so i dont know what i need to share

vivid vale
#

Wlle let's see. Your package.json and file structure for a start

raven wagon
#
const { app, BrowserWindow } = require('electron');
const path = require('node:path');

const createWindow = () => {
  // Create the browser window.
  const mainWindow = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
      preload: path.join(__dirname, 'preload.js')
    }
  })

  mainWindow.loadFile('index.html')
}

console.log(app)
app.whenReady().then(() => {
  createWindow()

  app.on('activate', () => {
    if (BrowserWindow.getAllWindows().length === 0) createWindow()
  })
})

app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') app.quit()
})
vivid vale
#

what's the name of this file?

raven wagon
#

app.js

vivid vale
#

okay

#

you don't start if with electron

#

"scripts": {
"start": "node app.js"
},

#

this script is wrong

raven wagon
#

what would be correct then?

vivid vale
#

I suggest you read the quick start guide

raven wagon
#

it gave me an error so i didnt think it would work

vivid vale
#

why instructions in the official quick start guide would not work?

raven wagon
#

thats a very good question