title: Electron - preload.js is not loaded and error is occurred on Windows 10
body: <p>When I built <code>npm start</code> the app on Windows 10, it does not work normally which worked fine on macOS.</p>
  <p>package.json</p>
  <pre><code>{
    &quot;name&quot;: &quot;SimpleTimer&quot;,
    &quot;version&quot;: &quot;1.0.0&quot;,
    &quot;productName&quot;: &quot;SimpleTimer&quot;,
    &quot;copyright&quot;: &quot;&quot;,
    &quot;description&quot;: &quot;&quot;,
    &quot;main&quot;: &quot;main.js&quot;,
    &quot;scripts&quot;: {
      &quot;start&quot;: &quot;node_modules/.bin/electron .&quot;,
      &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;,
    },
    &quot;keywords&quot;: [],
    &quot;author&quot;: &quot;&quot;,
    &quot;license&quot;: &quot;MIT&quot;,
    &quot;devDependencies&quot;: {
      &quot;electron&quot;: &quot;^10.1.2&quot;
    }
  }
  </code></pre>
  <p>I got the following error message.</p>
  <p><a href="https://i.stack.imgur.com/xcLGw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xcLGw.png" alt="enter image description here" /></a></p>
  <p><code>TypeError: ipcMain.handle is not a function</code> where this applies:</p>
  <p>main.js</p>
  <pre class="lang-js prettyprint-override"><code>ipcMain.handle(&quot;ipc-timer-start&quot;, () =&gt; {
    if ( isWorking === true ) {
      return true
    }
    else {
      StartTimer();
      isWorking = true;
    }
    return true;
  });
  </code></pre>
  <p>This function is the recipient of the ipc communication from <code>ipcRenderer.invoke()</code> written in <code>preload.js</code>. That's the <code>invoke()</code> method in <code>TimerStart</code> api in the following source.</p>
  <p>preload.js</p>
  <pre class="lang-js prettyprint-override"><code>const { contextBridge, ipcRenderer} = require(&quot;electron&quot;);
  
  contextBridge.exposeInMainWorld(
    &quot;api&quot;, {
      TimerStart: () =&gt;
          ipcRenderer.invoke(&quot;ipc-timer-start&quot;)  /*** HERE ***/
              .then(result =&gt; result)
              .catch(err =&gt; console.log(err)),
  
      TimerStop: () =&gt; ipcRenderer.send(&quot;ipc-timer-stop&quot;),
  
      TimerReset: () =&gt; ipcRenderer.send(&quot;ipc-timer-reset&quot;),
  
      DisplayTimer: (channel, listener) =&gt; {
        ipcRenderer.on(&quot;ipc-display-timer&quot;, (event, arg) =&gt; listener(arg));
      }
    }
  );
  </code></pre>
  <p>Of course, <code>preload.js</code> is specified when it created the <code>BrowserWindow</code>.</p>
  <p>main.js</p>
  <pre class="lang-js prettyprint-override"><code> mainWindow = new BrowserWindow({
      title: config.name,
      width: 1024,
      height: 640,
      minWidth: 1024,
      minHeight: 640,
      webPreferences: {
        worldSafeExecuteJavaScript: true,
        nodeIntegration: false,
        contextIsolation: true,
        preload: __dirname + '/preload.js'  /*** HERE ***/
      }
    });
  </code></pre>
  <p>After skipping this error message dialog, I checked with the DevTools and it looks like <code>preload.js</code> is not loaded from the statement of <code>Unable to load preload script:</code>.</p>
  <p><a href="https://i.stack.imgur.com/GJLnZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GJLnZ.png" alt="enter image description here" /></a></p>
  <p>Given these statements, it seems that <code>preload.js</code> is not properly included in the build, what should I do?</p>
  <p>Once again, it worked fine on macOS, but it doesn't work properly on Windows 10 due to these issues.</p>