Comments (8)
For the records, 1.4.1 works for my setting. Thanks!
from electron-reload.
You can use something like path.join(__dirname, '..')
to access files from the location of you entry point.
from electron-reload.
The problem is not on the user side, but on the library side, as it crashes executing the following line when the module is imported
Line 10 in 6ad1a18
It requires a non-existing file based on the (not-necessarily true) assumption that
package.json
lies in the same folder of the program entry-point.from electron-reload.
It may differ between the operation systems but getAppPath()
should point to the location from where you are starting the app. If you are starting it with electron .
(and not electron ./main/main.js
) from the root of you project then it will find the package.json
from electron-reload.
I cannot reproduce the problem without knowing how your project is structured. Usually you define the entry point in the package.json
and start the electron by pointing it to the directory including the package.json
. Doing so would result in getAppPath()
returning the directory in which the package.json
is also located.
from electron-reload.
I think we can simplify the application logic by removing
Line 10 in 6ad1a18
Line 11 in 6ad1a18
const mainFile = __filename
It should work as electron-reload
is always initiated by the main file. @marcoancona could you give it a try and let me know? Thanks.
from electron-reload.
Yes, using const mainFile = __filename
works for me. Alternatively, one could pass the path of mainFile
optionally? This would handle all edge cases I guess.
For completeness, I should mention that the main
in my package.json
points to dist/main/main.js
as in production the app is transpiled into a dist
folder. This is the reason why, in development mode, I must run the app with electron main/main.js
instead of electron .
from electron-reload.
So it turned out that __filename
returns the location of electron-reload
and not the parent file require
ing it. So I was wrong. But I changed it to const mainFile = module.parent.filename
and I suppose it should work now. I'll publish a new version and you can try it then.
from electron-reload.
Related Issues (20)
- Return watcher from elecronReload()
- Doesn't relaunch when main process file is changed HOT 1
- Can't update electron main process.
- SoftResetHandler can not be disabled
- Wrong typing of ARGV in typescript definition
- Electron-reload dynamic import fails
- allow array of globs
- C
- B
- Error occurs with latest electron: Cannot read properties of undefined (reading 'app')
- This package causes openDevTools to not work
- Execute code before reloading HOT 1
- Can't import (the CJS) electron-reload from ESM modules, due to use of deprecated CJS feature: module.parent HOT 2
- Cannot read property 'filename' of undefined HOT 6
- Error loading the moduel HOT 1
- Chokidar error on windows HOT 1
- Uncaught TypeError: Cannot read property 'app' of undefined` in `electron-reload/main.js HOT 1
- App reloads on save but changes are not applied HOT 1
- Use dinamic `main` instead of index.js HOT 1
- forceHardReset:false not working... I am changing settings.json file in app directory by fs module, but It lead to DOM reset that I dont want, I am also using dialog.showOpenDialogSync(), idk that cause this problem...
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from electron-reload.