Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 292
SteveB Avatar asked May 27 '16 17:05

SteveB


4 Answers

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"
}
like image 145
Abraham Jagadeesh Avatar answered Nov 11 '22 02:11

Abraham Jagadeesh


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"
  }
}
like image 13
Mr. Ratnadeep Avatar answered Nov 11 '22 04:11

Mr. Ratnadeep


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;  
like image 9
Penkey Suresh Avatar answered Nov 11 '22 04:11

Penkey Suresh


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.

like image 6
Kiran Maniya Avatar answered Nov 11 '22 04:11

Kiran Maniya