electron-rebuild "Unable to find Electron app ..."

41,165

Solution 1

Check if your package.json has "main" key. Here main.js is your Electron Configuration JS file.

{
  "name": "appname",
  "version": "0.0.0",
  "license": "MIT",
  "main": "main.js"
}

Solution 2

The entry point file name and package.json main file name should be same. Consider your entry point file name is app.js then package.json looks like

{
  "name": "myelectron",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "electron ."
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "electron": "^2.0.3"
  }
}

Solution 3

For me it was throwing this error because of missing package.json file in the folder I was running electron command. Make sure the folder consists of files named

  1. main.js
  2. index.html
  3. package.json

and define variables electron, app and BrowserWindow in main.js are as

               const electron = require('electron');             
               const {app, BrowserWindow} = electron;  

Solution 4

Make sure you defined entry point for the application. generally, it's always a index.js or main.js. You need to specify in package.json as an entry point of application. In this case what happened is, electron need the entry point and it didn't find from package.json and unable to start the main process. To fix it up, You can add main property as root property in package.json as given below,

{
  "name": "YOUR_APP_NAME",
  "version": "1.0.0",
  "main": "main.js"
}

Another important thing is, just check once the dependencies by running command npm list --depth=0 and confirm that electron is there.

Solution 5

for me the issue was caused due to inconsistency with the name when running the Electron command.

Ensure that the filename provided for run should be the same as the one provided in the main entry in package.json e.g. on Mac OS /Applications/Electron.app/Contents/MacOS/Electron hello-world matches with the hello-world.js in main package.json

{
  "name": "first_electron_app",
  "version": "0.0.1",
  "main": "hello-world.js",
  "dependencies": {    
  }
}

Share:
41,165
SteveB
Author by

SteveB

Programmer, Writer

Updated on July 21, 2022

Comments

  • SteveB
    SteveB 10 months

    After installing a native module via npm for use with Electron (atom shell) I'm trying to run electron-rebuild:

    >>./node_modules/.bin/electron-rebuild
    

    from the project directory,b "~/project_js/React-Redux-Py-Electron/" (which contains node_modules/). But I receive this error message:

    >>Unable to find Electron app at ~/project_js/React-Redux-Py-Electron/console.log(process.versions.modules)
    

    Using versions:

    node v6.2.0, 
    npm 3.8.9, 
    electron-prebuilt 1.2.0, 
    electron-rebuild 1.1.4, 
    

    which I believe are all the latest. At one time, perhaps before some version upgrades, this worked.

    Can anyone explain and suggest a fix? Thanks.

  • JimmyBlu
    JimmyBlu almost 6 years
    Both commands depend on what they are configured for in package.json / scripts, so this information is of no use without the contents of package.json
  • Balaj Khan
    Balaj Khan over 4 years
    Solved the issue :)
  • Pramod
    Pramod over 3 years
    it did fix for me.