electron-userland / electron-json-storage

:package: Easily write and read user settings in Electron apps
1.43k stars 79 forks source link

Electron v14 support #168

Closed juanmartin closed 2 years ago

juanmartin commented 2 years ago

Hi, I've just updated Electron to latest v14.0.1 and can't set the data path. I always get the Error: You must explicitly set a data path.

This is my config for the main Window:

webPreferences: {
      nodeIntegration: true,
      contextIsolation: false,
      enableRemoteModule: true, // also tried with false, without success
}

I've used storage.setDataPath(storagePath); where I pass the storagePath through IPC to the renderer process. Also tried setting the data path in the main process, but still get the error. Calling storage.getDefaultDataPath() returns null Calling storage.getDataPath() returns the set path.

I've migrated the project to use '@electron/remote' as it has been fully deprecated.

Let me know what other info can I provide to help debug this.

Thank you in advance!

juanmartin commented 2 years ago

UPDATE: Fixed my own issue. The problem was that I was calling asynchronously to get the storage path from the main process, so the module was initialized before having the path set. I switched to ipcRenderer.sendSync and was able to make it work. I realized about this because one of the things I tried was to hardcode the path, and it worked.

Leaving this here for future reference. Thanks!

jviotti commented 2 years ago

Glad you got it solved!