Closed Holybasil closed 3 years ago
Hey @Holybasil,
I believe you need to set nodeIntegration: true
in order to access the process
global object.
What I think its happening is that you can always access process
at this point. If the environment is production, then you don't enable nodeIntegration
on that renderer process, which eventually makes rimraf
crash, as that module presumable does try to access process
.
In summary, this doesn't seem related to electron-json-storage
, but to the fact that another module (rimraf
) is trying to access process
, which you are disabling if the environment is production.
I have found a solution.
main.js
import Storage from 'electron-json-storage';
Storage.set("foo", {value: false});
ipcMain.handle(
'getStoreValue',
(event, key) =>
new Promise((resolve, reject) => {
Storage.get(key, (error, data) => {
if (error) {
reject(error);
} else {
resolve(data);
}
});
})
);
renderer.js
import { ipcRenderer } from 'electron';
ipcRenderer
.invoke('getStoreValue', 'foo')
.then(data => console.log(data, 'data')); // {value: false} "data"
And 'set' is just like this way.
electron: 8.2.0 electron-json-storage: 4.2.0
And,