Usage of electron-store in Renderer Processes
See original GitHub issueGreetings, I need some help 🙏 I’ve been trying to implement some data persistance using electron-store. But somehow, when I import it in the renderer process, the compilation keeps failing and throwing errors. I’m using VueJS.
The error messages
Module not found: Error: Can't resolve 'path' ...
Module not found: Error: Can't resolve 'fs' ...
Module not found: Error: Can't resolve 'crypto' ...
config.js which is located in src folder.
const Store = require('electron-store');
const schema = {
general: {
type: 'object',
properties: {
gpu: { type: 'boolean' },
openOnStartup: { type: 'boolean' },
tray: { type: 'boolean' },
},
default: {
gpu: true,
openOnStartup: false,
tray: true,
}
},
theme: {
type: 'object',
properties: {
modes: {
type: 'string',
enum: ['dark', 'light', 'system'],
default: 'dark',
},
themes: {
type: 'object',
properties: {
name: { type: 'string'},
colours: {
type: 'array',
items: {
type: 'string'
},
// TODO: Add default theme
default: [],
}
}
}
}
}
};
const config = new Store({schema});
export default config;
<script>
import config from "/src/config";
console.log(config.get('general'))
</script>
Importing it only into the main process works fine. But the adding it to a renderer process from a vue component throws those errors mentioned above.
package.json dependencies
"dependencies": {
"electron": "^15.3.1",
"electron-store": "^8.0.1",
}
Tried to follow the same configuration as Caprine’s config but I still get the same errors.
Issue Analytics
- State:
- Created 2 years ago
- Comments:11
Top Results From Across the Web
How to store local data with electron-store and get these data ...
So your only option to send and received data between the main and renderer processes is by using ipc messaging.
Read more >Electron Store
Electron strongly recommends disabling node integration in the renderer process, which is now the default. IPC is required to securely pass values between...
Read more >Deep dive into Electron's main and renderer processes
Electron uses interprocess communication (IPC) to communicate between processes — same as Chromium. IPC is sort of like using postMessage ...
Read more >Using Typescript with electron-store - Ryosuke
Why use electron-store? · Local Storage and cookies require you to JSON. · electron-store is built with ajv, a data validation library (similar...
Read more >Top 5 electron-store Code Examples - Snyk
How to use electron-store - 10 common examples · To help you get started, we've selected a few electron-store examples, based on popular...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You literally documented you can use it in the renderer process here: https://github.com/sindresorhus/electron-store#initrenderer
Persistent storage needs to access your hard disk. You can’t access your hard disk directly in the rendering process, so the build will report an error