yhirose/react-typescript-electron-sample-with-create-react-app-and-electron-builder

when i change main.ts throw error flash back window

icyfe opened this issue · 3 comments

icyfe commented

node : 12.14.1
electorn: 9.0.0
platform: winx64
Hi~ when i change main.ts throw error flash back window,

image

can you help for me look forward to your answer!

Remove '..', at hot reloading bloc.

The treatment should be like this (./electron/main.ts) :

// Hot Reloading
  if (isDev) {
    // 'node_modules/.bin/electronPath'
    require('electron-reload')(__dirname, {
      electron: path.join(__dirname, '..', 'node_modules', '.bin', 'electron'),
      forceHardReset: true,
      hardResetMethod: 'exit'
    });
  }

Remove '..', at hot reloading bloc.

The treatment should be like this (./electron/main.ts) :

// Hot Reloading
  if (isDev) {
    // 'node_modules/.bin/electronPath'
    require('electron-reload')(__dirname, {
      electron: path.join(__dirname, '..', 'node_modules', '.bin', 'electron'),
      forceHardReset: true,
      hardResetMethod: 'exit'
    });
  }

Didn't work for me.

What did work is replacing 'electron' with 'electron.cmd':

// Hot Reloading

  if (isDev) {
    require("electron-reload")(__dirname, {
      electron: path.join(
        __dirname,
        "..",
        "..",
        "node_modules",
        ".bin",
        "electron" + (process.platform === "win32" ? ".cmd" : "")
      ),
      forceHardReset: true,
      hardResetMethod: "exit",
    });
  }

Fixed at #26.