right now i'm trying to learn how to program a desktop app using electron but I'm getting this error when trying to run 'npm start' using electron-prebuilt with nodejs x32 on windows 10 x64:
App threw an error during load
Error: Cannot find module 'browser-window'
at Module._resolveFilename (module.js:438:15)
at Function.Module._resolveFilename (C:\Users\Alejandro\Documents\Proyectos\player\node_modules\electron-prebuilt\dist\resources\electron.asar\common\reset-search-paths.js:35:12)
at Function.Module._load (module.js:386:25)
at Module.require (module.js:466:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\Alejandro\Documents\Proyectos\player\index.js:4:25)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:456:32)
at tryModuleLoad (module.js:415:12)
This is my code:
package.json
{
"name": "player",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "electron ."
},
"author": "",
"license": "ISC",
"dependencies": {},
"devDependencies": {
"electron-prebuilt": "^1.2.7"
}
}
index.js
const electron = require('electron')
const {app} = electron
const {BrowserWindow} = require('browser-window')
app.on('ready',function(){
var mainWindow = new BrowserWindow({
width:800,
height:600
})
})
node version: 4.4.5
npm version: 2.15.5
@morecchia808 is correct, the way built-in modules are accessed has changed in Electron v1.0. Your code can be fixed as follows:
const electron = require('electron')
const {app, BrowserWindow} = electron
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