<ul dir="auto">
<li><strong>Electron Version</strong>
<ul dir="auto">
<li>4.0.5  ( run as node: 10.11.0 )</li>
</ul>
</li>
<li><strong>Operating System</strong> (Platform and Version):
<ul dir="auto">
<li>Windows 10 (1809)</li>
</ul>
</li>
<li><strong>Last known working Electron version</strong> (if applicable):
<ul dir="auto">
<li>N/A</li>
</ul>
</li>
</ul>
<h3 dir="auto">Expected Behavior</h3>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;node --experimental-worker app.js
hello from electron as node
hello from main thread
hello from electron as node
hello from worker thread
hello from worker
0

&gt;node -v
v10.11.0"><pre class="notranslate"><span class="pl-k">&gt;</span>node --experimental-worker app.js
hello from electron as node
hello from main thread
hello from electron as node
hello from worker thread
hello from worker
0

<span class="pl-k">&gt;</span>node -v
v10.11.0</pre></div>
<h3 dir="auto">Actual behavior</h3>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;electron --experimental-worker app.js
hello from electron as node
hello from main thread

&gt;electron -v
v10.11.0"><pre class="notranslate"><span class="pl-k">&gt;</span>electron --experimental-worker app.js
hello from electron as node
hello from main thread

<span class="pl-k">&gt;</span>electron -v
v10.11.0</pre></div>
<h3 dir="auto">To Reproduce</h3>
<p dir="auto">[app.js]</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="console.log(&quot;hello from electron as node&quot;)
const {
    Worker,
    isMainThread,
    parentPort
} = require('worker_threads');

if (isMainThread) {
    console.log(&quot;hello from main thread&quot;)
    function createWorker() {
        let worker = new Worker(__filename);
        worker.on('message', (msg) =&gt; {
	    console.log(msg);
        });
        worker.on('error', (err) =&gt; {
            console.log(err);
        });
        worker.on('exit', (code) =&gt; {
            console.log(code);
        });
    }
    createWorker();
} else {
   console.log(&quot;hello from worker thread&quot;)
   parentPort.postMessage(&quot;hello from worker&quot;);
}"><pre class="notranslate"><span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">"hello from electron as node"</span><span class="pl-kos">)</span>
<span class="pl-k">const</span> <span class="pl-kos">{</span>
    Worker<span class="pl-kos">,</span>
    isMainThread<span class="pl-kos">,</span>
    parentPort
<span class="pl-kos">}</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">'worker_threads'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">isMainThread</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">"hello from main thread"</span><span class="pl-kos">)</span>
    <span class="pl-k">function</span> <span class="pl-en">createWorker</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-k">let</span> <span class="pl-s1">worker</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">Worker</span><span class="pl-kos">(</span><span class="pl-s1">__filename</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
        <span class="pl-s1">worker</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s">'message'</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-s1">msg</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
	    <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s1">msg</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
        <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
        <span class="pl-s1">worker</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s">'error'</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-s1">err</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
            <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s1">err</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
        <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
        <span class="pl-s1">worker</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s">'exit'</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-s1">code</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
            <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s1">code</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
        <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span>
    <span class="pl-en">createWorker</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span> <span class="pl-k">else</span> <span class="pl-kos">{</span>
   <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">"hello from worker thread"</span><span class="pl-kos">)</span>
   <span class="pl-s1">parentPort</span><span class="pl-kos">.</span><span class="pl-en">postMessage</span><span class="pl-kos">(</span><span class="pl-s">"hello from worker"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<h3 dir="auto">Issue Details</h3>
<ul dir="auto">
<li><strong>Electron Version:</strong><br>
v5.0.2</li>
<li><strong>Operating System:</strong><br>
Windows 10</li>
</ul>
<h3 dir="auto">Expected Behavior</h3>
<p dir="auto">On app ready start nodejs worker which consoles string.</p>
<h3 dir="auto">Actual Behavior</h3>
<p dir="auto">App crash immediately after run</p>
<h3 dir="auto">To Reproduce</h3>
<ul dir="auto">
<li>git clone <a href="https://github.com/BorysTyminski/electron-issue.git">https://github.com/BorysTyminski/electron-issue.git</a></li>
<li>cd electron-issue</li>
<li>npm install</li>
<li>npm run start</li>
</ul>
<h3 dir="auto">Additional Information</h3>
<p dir="auto">I used electron-forge to quick build app.</p>