How can I get open/save dialog to work on Electron v19?

Viewed 14

I am quite new to Electron and am trying to make a note app where you can save and open note files. I am trying to set up a page where you can open a file. I have been following a few tutorials, but none of them seem to be working. I try:

const { dialog, app } = require('electron')

dialog.showOpenDialogSync(mainWindow, {
  properties: ['openFile', 'openDirectory']
})

and my html is:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Test</title>
    <script src="app.js"></script>
  </head>
  <body>
    <h1>Test</h1>
      
  </body>
</html>

but I get this error in console:

Uncaught TypeError: Cannot read properties of undefined (reading 'showOpenDialogSync')
    at app.js:3:8
0 Answers
Related