I've electron app with Angular frontend. I'm trying to use Store in the renderer process as described in the README file
Here is my code for preload and electron-main.js:
preload.js file:
const { ipcRenderer, contextBridge } = require("electron");
const Store = require("electron-store");
const store = new Store({
encryptionKey: "my-secret-encryption-key",
});
electron-main.js file:
const Store = require("electron-store");
Store.initRenderer();
const createWindow = () => {
win = new BrowserWindow({
width: 400,
height: 600,
autoHideMenuBar: true,
webPreferences: {
preload: path.join(__dirname, "./src/app/app-preload.js"),
},
});
win.loadURL("http://localhost:4200/"); // For local development builds
};
app.whenReady().then(() => {
createWindow();
app.on("activate", () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
});
When I use Store in above way I got the error:
Unable to load preload script: /home/Documents/todo-desktop/src/app/app-preload.js
(anonymous) @ VM4 sandbox_bundle:2
VM4 sandbox_bundle:2 Error: module not found: electron-store
at preloadRequire (VM4 sandbox_bundle:2:82751)
at :3:15
at runPreloadScript (VM4 sandbox_bundle:2:83503)
at VM4 sandbox_bundle:2:83762
at VM4 sandbox_bundle:2:83917
at _electron_webpack_init (VM4 sandbox_bundle:2:83921)
at VM4 sandbox_bundle:2:84044
(anonymous) @ VM4 sandbox_bundle:2
As soon as I remove Store from preload.js file, I didn't get any error.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too