Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

electron-prebuilt renamed #16

Closed
keverw opened this issue Oct 23, 2016 · 19 comments
Closed

electron-prebuilt renamed #16

keverw opened this issue Oct 23, 2016 · 19 comments

Comments

@keverw
Copy link

keverw commented Oct 23, 2016

http://electron.atom.io/blog/2016/08/16/npm-install-electron

I went ahead and updated my project and removed prebuilt.

My code is:

require('electron-reload')(__dirname, {
        electron: require('electron')
    });

but I get "Electron could not be found. No hard resets for you!" when I start my app...

@yan-foto
Copy link
Owner

So you are only gonna have soft resets. I don't get the question?

@yan-foto yan-foto reopened this Oct 24, 2016
@keverw
Copy link
Author

keverw commented Oct 24, 2016

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.

@yan-foto
Copy link
Owner

yan-foto commented Oct 24, 2016

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.

@keverw
Copy link
Author

keverw commented Oct 24, 2016

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.

@yan-foto
Copy link
Owner

I will check this later today and update the documentation. Thanks for the heads up and sorry for the initial misunderstanding!

@ghost
Copy link

ghost commented Oct 27, 2016

Do you have an update on this?

@yan-foto
Copy link
Owner

@JBodkin not yet. pull requests are welcome!

@ghost
Copy link

ghost commented Oct 30, 2016

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')
})

@yan-foto
Copy link
Owner

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. 👍 .

@yan-foto
Copy link
Owner

yan-foto commented Nov 5, 2016

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!

@yan-foto yan-foto closed this as completed Nov 5, 2016
@yan-foto
Copy link
Owner

@Peter-Gess can depend on many things. You better should consult stackoverflow. Issues are preferably only for bugs.

@doncolio007
Copy link

Thanks @JBodkin. Fixed

@hari03
Copy link

hari03 commented Feb 8, 2018

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!

@rachidsakara
Copy link

rachidsakara commented Jun 29, 2018

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') })

@Eshva
Copy link

Eshva commented Jul 4, 2018

@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`) })

@rachidsakara
Copy link

rachidsakara commented Jul 5, 2018 via email

@rachidsakara
Copy link

rachidsakara commented Jul 5, 2018 via email

@Eshva
Copy link

Eshva commented Jul 5, 2018

It will not. I've checked. For string interpolation you have to use backtick and you use single quote.

@anderm8
Copy link

anderm8 commented Mar 25, 2019

Just FYI, backtick works, single quote did not for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants