Open mnmkay opened 6 months ago
I solve this problem like this:
import electronReloader from "electron-reloader"; if (process.env.NODE_ENV === "development") { try { module.path = __dirname; module.filename = __filename; electronReloader(module, { watchRenderer: true }); } catch (err: any) { console.log(err); } }
I don't know why (I think, webpack is causing this.) but when I run the program, the filename and dirname is not defined so I defined it hardly and it worked.
It's electron-reload, not electron-reloader. I have the same problem.
I solve this problem like this:
import electronReloader from "electron-reloader"; if (process.env.NODE_ENV === "development") { try { module.path = __dirname; module.filename = __filename; electronReloader(module, { watchRenderer: true }); } catch (err: any) { console.log(err); } }
I don't know why (I think, webpack is causing this.) but when I run the program, the filename and dirname is not defined so I defined it hardly and it worked.
It's electron-reload, not electron-reloader. I have the same problem.
Oww you are right! Sorry guys :D I confused them.
Here is electron-reload's source use of module.parent
Here is discussion about module.parent's problem with being imported, import(CJS)
Here is deprecation commit that suggests testing require.main
To test, run a single-line ESM file from node: TEST.mjs:
Output