electron-userland / electron-json-storage

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

'The "path" argument must be of type string. Received null' in electron-json-storage #179

Closed kochizufan closed 2 years ago

kochizufan commented 2 years ago

Maybe this post is kinda multi-post, but I want to fix this ASAP..

https://stackoverflow.com/questions/71897989/the-path-argument-must-be-of-type-string-received-null-in-electron-json-sto

jviotti commented 2 years ago

Can you create an Electron Fiddle or a basic repo reproducing the issue?

kochizufan commented 2 years ago

Sorry I found the reason...

I call "electron-json-storage" inside of "preload.js". I don't know "preload.js" is worked on renderer process. I must use electron-json-storage on main process.

I realized that under the contextIsolation environment, I need to completely rethink my architecture from the nodeIntegration era configuration.

kochizufan commented 2 years ago

I created example for using electron-json-storage under contextIsolation environment for people who will have similar question in future: https://gist.github.com/kochizufan/a467c6b76390c6f1c41260614cb06a5c

This works well. NOTE: Error handling or avoiding multiple registration of api are totally omitted in this example.

Any points for improvement are welcome.