SteveB
SteveB

Reputation: 981

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.

Upvotes: 54

Views: 61612

Answers (6)

pg2286
pg2286

Reputation: 1021

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": {    
  }
}

Upvotes: 5

Kiran Maniya
Kiran Maniya

Reputation: 8979

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.

Upvotes: 7

Mr. Ratnadeep
Mr. Ratnadeep

Reputation: 621

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"
  }
}

Upvotes: 16

Abraham Jagadeesh
Abraham Jagadeesh

Reputation: 1947

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"
}

Upvotes: 106

Penkey Suresh
Penkey Suresh

Reputation: 5974

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;  

Upvotes: 9

Trey Huffine
Trey Huffine

Reputation: 242

npm run build && npm start fixed it for me

Upvotes: 1

Related Questions