<ul dir="auto">
<li>Electron version: 0.37.2 + 0.36.12</li>
<li>Operating system: OS X 10.11.4 (15E65)</li>
</ul>
<p dir="auto">The process doesn't seem to exit like <code class="notranslate">node</code> does. I've reduced it to something <code class="notranslate">babel-register</code> is doing. I'm not sure if this is a bug within babel or electron, so feel free to close this if it's a bug with babel. It's the same behavior on both 0.37.2 and 0.36.12.</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# works properly, does nothing and exits
node -e &quot;require('babel-register')&quot;

# hangs forever until you ctrl+c
ELECTRON_RUN_AS_NODE=true node_modules/.bin/electron -e &quot;require('babel-register')&quot;"><pre class="notranslate"><span class="pl-c"><span class="pl-c">#</span> works properly, does nothing and exits</span>
node -e <span class="pl-s"><span class="pl-pds">"</span>require('babel-register')<span class="pl-pds">"</span></span>

<span class="pl-c"><span class="pl-c">#</span> hangs forever until you ctrl+c</span>
ELECTRON_RUN_AS_NODE=true node_modules/.bin/electron -e <span class="pl-s"><span class="pl-pds">"</span>require('babel-register')<span class="pl-pds">"</span></span></pre></div>
<p dir="auto">A complete test:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="mkdir electron-node-hang
cd electron-node-hang
npm init -y
npm install electron-prebuilt babel-register --save
ELECTRON_RUN_AS_NODE=true node_modules/.bin/electron -e &quot;require('babel-register')&quot;"><pre class="notranslate">mkdir electron-node-hang
<span class="pl-c1">cd</span> electron-node-hang
npm init -y
npm install electron-prebuilt babel-register --save
ELECTRON_RUN_AS_NODE=true node_modules/.bin/electron -e <span class="pl-s"><span class="pl-pds">"</span>require('babel-register')<span class="pl-pds">"</span></span></pre></div>
<h2 dir="auto">Description</h2>
<p dir="auto">Our project is using <code class="notranslate">child_process#fork()</code> to run npm commands, but it turns out taking much longer time than normal.<br>
I haven't tested if this problem occurs when running other scripts, but as shown in the test below, running the same code in pure <code class="notranslate">node</code> behaves normally.</p>
<h2 dir="auto">Reproduction</h2>
<ol dir="auto">
<li>In a new folder, clone an empty app: <code class="notranslate">git clone https://github.com/atom/electron-quick-start</code></li>
<li><code class="notranslate">cd</code> into that directory and install npm locally: <code class="notranslate">npm i npm</code></li>
<li>Open this app: <code class="notranslate">electron .</code></li>
<li>In the console, run the following code</li>
</ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="var npmpath=require('path').join(__dirname,'node_modules','.bin','npm');
var startTime=new Date().getTime();
var cp=require('child_process');
var child = cp.fork(npmpath,['dist-tag','ls','npm'],{stdio:'pipe',silent:true});
child.stdout.on('data', function(data) {
    console.log('stdout: ' + data);
});
child.stderr.on('data', function(data) {
    console.log('stdout: ' + data);
});
child.on('close', function(code) {
    console.log('closing code: ' + code);
    console.log('time: ' + (new Date().getTime()-startTime));
});"><pre class="notranslate"><code class="notranslate">var npmpath=require('path').join(__dirname,'node_modules','.bin','npm');
var startTime=new Date().getTime();
var cp=require('child_process');
var child = cp.fork(npmpath,['dist-tag','ls','npm'],{stdio:'pipe',silent:true});
child.stdout.on('data', function(data) {
    console.log('stdout: ' + data);
});
child.stderr.on('data', function(data) {
    console.log('stdout: ' + data);
});
child.on('close', function(code) {
    console.log('closing code: ' + code);
    console.log('time: ' + (new Date().getTime()-startTime));
});
</code></pre></div>
<p dir="auto">On my computer it takes about 36 seconds,<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/1596656/12667586/35996b1e-c613-11e5-9b30-cbe14d4d52f9.png"><img src="https://cloud.githubusercontent.com/assets/1596656/12667586/35996b1e-c613-11e5-9b30-cbe14d4d52f9.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">On the other hand, to test it in pure node,</p>
<ol dir="auto">
<li>Save the script above in the root directory of the same app as <code class="notranslate">run.js</code></li>
<li><code class="notranslate">node run.js</code></li>
</ol>
<p dir="auto">On my computer it takes about 1.2 seconds, which is about the same as directly running this command in command line.<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/1596656/12667603/7d7a64c4-c613-11e5-90be-7a2ca47d3648.png"><img src="https://cloud.githubusercontent.com/assets/1596656/12667603/7d7a64c4-c613-11e5-90be-7a2ca47d3648.png" alt="image" style="max-width: 100%;"></a></p>
<h2 dir="auto">Platform</h2>
<ul dir="auto">
<li>node 5.1.1</li>
<li>Chrome 47.0.2526.110</li>
<li>Electron 0.36.5</li>
<li>OS X 10.11.3</li>
</ul>