6

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

3
  • I think you want: const BrowserWindow = electron.BrowserWindow. I don't believe browser-window is a separate module any more. Check out: github.com/electron/electron-quick-start Commented Jul 15, 2016 at 16:09
  • Thanks it worked :) Commented Jul 18, 2016 at 19:08
  • Can I create a build of pre-built app of node js using this? If yes then can you please guide me how? Commented Jan 2, 2017 at 7:34

1 Answer 1

14

@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 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.