1

I'm using the boilerplate react-photonkit/epp and everything is well executed on dev when running yarn start.

But then, when I want to package my app with yarn run build-osx, the app is generated but I have an error when launching it. This error appears only when I try to import electron. If not, the app is running in production.

Uncaught ReferenceError: electron is not defined

Here is my webpack config, the only thing I have added is target:"electron". I also tried with externals: {electron: "electron"}.

I tried to import dialog from electron like this:

const {dialog} = require('electron').remote;

Or

const {dialog} = window.require('electron').remote;

1 Answer 1

1

I managed to require the dialog modifying the target in the webpack config target:electron-renderer which import the module remote.

Then we can import it like this

const remote = window.require("electron").remote;
const dialog = remote.require('dialog');

And the I can use the dialog from electron. It's a workaround, I didn't figured out why electron was not available but it could be because of the really old version of electron and the electron-packager. This repo has not been updated for a while and the version were not fixed so it can create issue.

Anyway, for people trying this boilerplate, start with electron forge and electron-compile!

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.