Comments (19)
Looks to be related to the way require
works, when using the new package name
Previously the index.js
file would be loaded returning the path to the executable, Instead the electron.asar
is loaded.
I was able to work around this by providing a path to the index.js inside the module home instead.
require('electron-reload')(__dirname, {
electron: require('${__dirname}/../../node_modules/electron')
})
from electron-reload.
@rachidsakara Thank you for comment. It helped me. But the only thing you need to fix are quotes. You should use ` not ' for interpolation.
For instance the proper version of Option 3 is:
require('electron-reload')(__dirname, { electron: require(`${__dirname}/node_modules/electron`) })
from electron-reload.
I will check this later today and update the documentation. Thanks for the heads up and sorry for the initial misunderstanding!
from electron-reload.
make sure that the electron-reload module is installed locally in your project, if not the case Visit your console and type:
npm install electron-reload --save-dev
Now in order to implement this module in your project; the main file (index.js or main.js), you have tree options.
Option 1:
require('electron-reload')(__dirname)
Option 2:
require('electron-reload')(__dirname, { electron: require('${__dirname}/../../node_modules/electron') })
Option 3:
require('electron-reload')(__dirname, { electron: require('${__dirname}/node_modules/electron') })
from electron-reload.
So you are only gonna have soft resets. I don't get the question?
from electron-reload.
I changed electron-prebuilt
to electron
since they renamed the package. Before it gave hard resets. For some reason, the package renaming stopped those from working when using the reload module.
from electron-reload.
electron-prebuilt
still exists. I haven't yet played with the new one. I suppose you must have electron
as local dependency so require
actually finds it within your installed modules.
from electron-reload.
Yeah I had it installed locally. But I'm trying to do the two package.json build now - I discovered that earlier before I started on that. But I think in the future I want to move to TypeScript so i'd have to recompile and restart anyways from my understanding. So soft restarts would probably be good enough for my needs.
from electron-reload.
Do you have an update on this?
from electron-reload.
@JBodkin not yet. pull requests are welcome!
from electron-reload.
I somehow suspected that require(
electrol)
doesn't return a file path, as electron-reload
only verifies if the path to electron executable exists.
I'll take a look at it. I would try to find another way, as require
(with or without your proposed solution) doesn't seem to be the right way to solve this problem in the long run.
Thanks for taking a look at it. 👍 .
from electron-reload.
Ok guys, I am going to close this issue. I took a look at the whole situation and realized that obviously you cannot require
electron
the way you do electron-prebuilt
. I enhanced the README
to address this issue. In short: use explicit path of electron
binary instead of require
!
from electron-reload.
@Peter-Gess can depend on many things. You better should consult stackoverflow. Issues are preferably only for bugs.
from electron-reload.
Thanks @JBodkin. Fixed
from electron-reload.
Just a small note.
For @JBodkin comment suggestion generally fixes this issue but only if electron
has been installed locally and is available inside your current development folder. Global install in your system doesn't fix the issue for me. I re-tried after a local install and it worked!
from electron-reload.
from electron-reload.
from electron-reload.
It will not. I've checked. For string interpolation you have to use backtick and you use single quote.
from electron-reload.
Just FYI, backtick works, single quote did not for me.
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.