Bundle error using webpack for Electron application `Cannot resolve module 'electron'`

MasterT picture MasterT · Dec 23, 2015 · Viewed 14.4k times · Source

I am trying to create an Electron application with React. I use Webpack to compile the React JSX syntax, but when I try to compile with webpack command, I got this error:

ERROR in ./app.jsx Module not found: Error: Cannot resolve module 'electron' in /Users/masterT/Downloads/gist

@ ./app.jsx 6:18-37

Here is the application code.

I am doing something wrong?

Thanks!

Answer

jnoleau picture jnoleau · Mar 19, 2016

A very simple solution :

const remote = window.require('electron').remote;

webpack will ignore this require