I'm new to electron and have made my first electron application, it runs normally running npm start but when using npm run I am unable to execute my application. (I am running ubuntu linux) The cli gives this error message when running the executable file:
A JavaScript error occurred in the main process
Uncaught Exception:
Error: Cannot find module '/home/user/Documents/dev/cocoa/cocoa-linux-x64/resources/app/index.js'
at Module._resolveFilename (module.js:455:15)
at Function.Module._resolveFilename (/home/user/Documents/dev/cocoa/cocoa-linux-x64/resources/electron.asar/common/reset-search-paths.js:35:12)
at Function.Module._load (module.js:403:25)
at Object.<anonymous> (/home/user/Documents/dev/cocoa/cocoa-linux-x64/resources/electron.asar/browser/init.js:171:8)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.runMain (module.js:590:10)
This is my package.json :
{
"name": "cocoa",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "electron main.js",
"package-linux" : "electron-packager . --platform=linux --arch=x64 --electron-version=1.4.13"
},
"author": "",
"license": "ISC",
"devDependencies": {
"electron-packager": "^8.7.1"
}
}
this is the main.js file :
const electron = require('electron')
const {app, BrowserWindow} = electron
app.on('ready', ()=> {
let win = new BrowserWindow({
width:400,
height:400
})
win.loadURL('http://google.com')
})
Does anyone know what I am doing wrong, thank you for your help.