yan-foto/electron-reload

Hard reset not working

Opened this issue · 5 comments

What is the problem

When enabling hard reset (providing an electron path in the options object) and changing the main.js (I changed the width of the window, in this case), Electron crashes and doesn't reload.

The following output is printed in the console:

(node:12608) UnhandledPromiseRejectionWarning: Error: spawn C:\Users\leont\projects\electron-reload\node_modules\.bin\electron ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:81:21)
eload\main.js:37:11)
    at Object.onceWrapper (events.js:313:26)
    at FSWatcher.emit (events.js:223:5)
    at FSWatcher.emitWithAll (C:\Users\leont\projects\electron-reload\node_modules\chokidar\index.js:524:8)
    at FSWatcher._emit (C:\Users\leont\projects\electron-reload\node_modules\chokidar\index.js:616:8)
    at C:\Users\leont\projects\electron-reload\node_modules\chokidar\lib\nodefs-handler.js:370:20
(node:12608) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a 
promise which was not handled with .catch(). (rejection id: 1)
(node:12608) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

So I suppose that it's just a missing .catch() block somewhere that produces this error.

How to reproduce

Do a basic electron setup with the file setup provided in Writing Your First Electron App, install electron-reload and run it as usual. Also provide the electron path and set hardResetMethod to exit. Then run electron with npm start and change the browser window width and save the file. It should crash now.

Additional information

Node: v12.18.0
OS: Windows
Electron: 9.0.4

Seems like this could be a problem with chokidar as well.

I had a similar problem and I solved it by adding .cmd here:
electron: path.join(__dirname, 'node_modules', '.bin', 'electron.cmd')

I'm having the same issue, with the exact same setup. The solution proposed by @Ali229 works, but spawns a new node window with every reload.

@leontepe

electron: path.join(__dirname, "node_modules", "electron", "dist", "electron.exe")
It works in my environment.

I hope this will help.

Seems to be solved!