yan-foto/electron-reload

Error Launching App

alex-cory opened this issue · 4 comments

What is the problem

I keep getting Error launching app
image

My directory structure looks like

/root          (aka /ui)
  /electron
    app.js <- main electron thread
  /src <- react code

How to reproduce

I have it set up like this in /root/electron/app.js

const electronPath = path.join(process.cwd(), 'node_modules', '.bin', 'electron')
// electron path? /Users/alex/code/searchable/ui/node_modules/.bin/electron

// const electronPath = path.join(__dirname, 'node_modules', '.bin', 'electron')
// electron path?  /Users/alex/code/searchable/ui/electron/node_modules/.bin/electron

const dirToWatch = process.cwd() + '/electron/app.js'
// dir to watch:  /Users/alex/code/searchable/ui/electron/app.js

// const dirToWatch = __dirname
// dir to watch:  /Users/alex/code/searchable/ui

console.log('electron path? ', electronPath)
console.log('dir to watch: ', dirToWatch)

if (is.dev()) require('electron-reload')(dirToWatch, {
  electron: electronPath
})

I'm not really sure what I'm messing up here because it looks like the electronPath and dirToWatch are pointing to the correct places.

Additional information

OS - Catalina
node - v12.6.0
electron - v7.1.1

It seems that you don't have electron installed (npm i electron) or somehow it doesn't find the executable (see the error message).

Electron is installed. If I comment out the electron-reload code, it works, but otherwise I get the error mentioned here.

I don't think we should get into debugging your app, but I suppose you have electron installed globally or are packaging your app without including electron as dependency. Note that this is a development package and should not be included in productive env.

@alex-cory You can change the path for the app by giving argv to electron-reload

reload(__dirname, {
  electron: path.resolve(__dirname, '../node_modules/.bin/electron'),
  argv: ['build/desktop.js'],
  forceHardReset: true
});