Electron: dialog.showOpenDialog not returning a promise?

The same happened to me and my workaround was to apply the then method and get the filePaths i.e

dialog.showOpenDialog({
   properties: ['openDirectory']
}).then((data) => {
   console.log(data.filePaths);
});

I think you are reading the wrong version of the documentation. Before version 6, dialog.showOpenDialog() returns a String[] rather than a Promise<Object>.

Here is the documentation:

  • v5.0.11
  • v6.0.0

Hope my answer can help you


Run npm outdated and check your version. In my version showOpenDialog was returning a string array and not a promise. After updating it, it worked.