title: Packaged Electron App fails to Find Node Modules
body: <p>I have an electron project that is setup using <a href="https://github.com/electron-userland/electron-forge" rel="nofollow noreferrer">electron-forge</a>. The app works fine locally, and I am trying to package it for distribution on various operating systems. However, when I package and compile the app and try to run it, I receive <code>cannot find module ...</code> errors like this:</p>
  
  <pre><code>A JavaScript error occurred in the main process
  Uncaught Exception:
  Error: Cannot find module 'electron-compile'
      at Module._resolveFilename (module.js:470:15)
      at Function.Module._resolveFilename (/usr/lib/my-app/resources/electron.asar/common/reset-search-paths.js:35:12)
      at Function.Module._load (module.js:418:25)
      at Module.require (module.js:498:17)
      at require (internal/module.js:20:19)
      at Object.&lt;anonymous&gt; (/usr/lib/my-app/resources/app/es6-shim.js:4:23)
      at Object.&lt;anonymous&gt; (/usr/lib/my-app/resources/app/es6-shim.js:10:3)
      at Module._compile (module.js:571:32)
      at Object.Module._extensions..js (module.js:580:10)
      at Module.load (module.js:488:32)
  </code></pre>
  
  <p>My build process is as follows:</p>
  
  <ol>
  <li>use <code>webpack</code> to bundle electron components into a single file</li>
  <li>package and compile using <code>electron-forge</code></li>
  </ol>
  
  <h3>webpack.config.js</h3>
  
  <pre><code>const path = require('path');
  const webpack = require('webpack');
  
  module.exports = {
    target: 'electron-main',
    resolve: {
      extensions: ['.js']
    },
    entry: [`${__dirname}/src/main.js`],
    output: {
      path: `${__dirname}/dist`,
      filename: 'main.js'
    },
    module: {
      exprContextCritical: false,
      rules: [
        {
          exclude: /node_modules/,
          test: /.(ui.js|s?css|html|png|jpe?g|ico|svg)$/,
          use: 'ignore-loader'
        }
      ]
    }
  };
  </code></pre>
  
  <h3>forge.config.js</h3>
  
  <pre><code>const path = require('path');
  
  module.exports = {
    "make_targets": {
      "win32": ["squirrel"],
      "linux": ["deb"]
    },
    "electronPackagerConfig": {
      "dir": 'dist',
      "ignore": [
        "src/scss",
        ".*scss",
        "README.md",
        ".gitignore",
        ".nvmrc",
        "gulpfile.js",
        "forge.config.js"
      ]
    },
    "electronInstallerDebian": {
      "icon": {
        "scalable": path.join(__dirname, 'src/assets/icons/debian/Icon.svg')
      },
      "productName": "MyProduct"
    },
    "electronWinstallerConfig": {
      "iconUrl": path.join(__dirname, 'src/assets/icons/windows/Icon.ico'),
      "name": "MyProduct"
    }
  };
  </code></pre>
  
  <p>What am I doing wrong here? it seems like the <code>electron.asar</code> that is constructed doesn't know how/where to find certain node_modules, but it was my impression that they would be included in the bundle created by <code>webpack</code>.</p>