Giter VIP home page Giter VIP logo

Comments (4)

SteveCastle avatar SteveCastle commented on June 15, 2024 4

The docs seem to be out of date as you can't create a store in the renderer process anymore. Everything works great if I only create my store in the main process and use IPC to communicate. Electron React Boilerplate project has some useful docs on this.

https://electron-react-boilerplate.js.org/docs/electron-store

from electron-store.

steve981cr avatar steve981cr commented on June 15, 2024 1

My solution was to make a super simple version of electron-store that works for my needs. At the time of this writing electron-store doesn't work with apps packaged with electron-forge, or at least it didn't work for me. I made a gist of what I did for anyone having this problem: https://gist.github.com/steve981cr/499dae0c2a4c6340d0f35656dae92020

from electron-store.

steve981cr avatar steve981cr commented on June 15, 2024

I ran into the same issue.

  • I get the error when packaging the app with Electron-Forge in Windows. This is Electron's recommended Packager.
  • I do not get the error on Mac.
  • I do not get the error on Windows if I use the Electron-Builder packager.
  • I have isolated the error to be caused if I use Electron Store. If I just comment out the use of it, the error goes away. And interestingly, if I use electron-settings instead of Electron-Store (they perform a similar function) I get the same type of error.

Attached is a screenshot of the error message I get.

electron-store-windows-error

from electron-store.

sintanial avatar sintanial commented on June 15, 2024

After some research, i found a solution:

  1. Need to add in main webpack config target: "electron-main",
import type {Configuration} from 'webpack';

import {rules} from './webpack.rules';
import {plugins} from './webpack.plugins';

export const mainConfig: Configuration = {
    entry: './src/index.ts',
    target: "electron-main", // <-- PUT IT HERE
    module: {
        rules,
    },
    plugins,
    resolve: {
        extensions: ['.js', '.ts', '.jsx', '.tsx', '.css', '.json'],
    },
};
  1. Need to add in renderer webpack config target: "electron-renderer",
import type { Configuration } from 'webpack';

import { rules } from './webpack.rules';
import { plugins } from './webpack.plugins';

rules.push({
  test: /\.css$/,
  use: [{ loader: 'style-loader' }, { loader: 'css-loader' }],
});

export const rendererConfig: Configuration = {
  target: "electron-renderer", // <-- PUT IT HERE
  module: {
    rules,
  },
  plugins,
  resolve: {
    extensions: ['.js', '.ts', '.jsx', '.tsx', '.css'],
  },
};

from electron-store.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.