Code Monkey home page Code Monkey logo

Comments (19)

 avatar commented on June 9, 2024 28

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.

Eshva avatar Eshva commented on June 9, 2024 3

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

yan-foto avatar yan-foto commented on June 9, 2024 1

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

from electron-reload.

rachidsakara avatar rachidsakara commented on June 9, 2024 1

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.

yan-foto avatar yan-foto commented on June 9, 2024

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

from electron-reload.

keverw avatar keverw commented on June 9, 2024

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.

yan-foto avatar yan-foto commented on June 9, 2024

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.

keverw avatar keverw commented on June 9, 2024

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.

 avatar commented on June 9, 2024

Do you have an update on this?

from electron-reload.

yan-foto avatar yan-foto commented on June 9, 2024

@JBodkin not yet. pull requests are welcome!

from electron-reload.

yan-foto avatar yan-foto commented on June 9, 2024

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.

yan-foto avatar yan-foto commented on June 9, 2024

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.

yan-foto avatar yan-foto commented on June 9, 2024

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

from electron-reload.

doncolio007 avatar doncolio007 commented on June 9, 2024

Thanks @JBodkin. Fixed

from electron-reload.

hari03 avatar hari03 commented on June 9, 2024

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.

rachidsakara avatar rachidsakara commented on June 9, 2024

from electron-reload.

rachidsakara avatar rachidsakara commented on June 9, 2024

from electron-reload.

Eshva avatar Eshva commented on June 9, 2024

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

from electron-reload.

anderm8 avatar anderm8 commented on June 9, 2024

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

from electron-reload.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.