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.
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"
}
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"
}
}
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
main.js
index.html
package.json
and define variables electron
, app
and BrowserWindow
in main.js
are as
const electron = require('electron');
const {app, BrowserWindow} = electron;
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With