<p dir="auto">When I perform</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import stuff from './stuff';"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">stuff</span> <span class="pl-k">from</span> <span class="pl-s">'./stuff'</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">in babel-node CLI, it silently works but trying to access <code class="notranslate">stuff</code> on the following lines throws a <code class="notranslate">ReferenceError: stuff is not defined</code>.</p>
<p dir="auto">When using an ES6 import at the <code class="notranslate">babel-node</code> REPL, it fails.</p>
<p dir="auto">Example sources:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// foo.js
import bar from './bar'
console.log(bar)"><pre class="notranslate"><span class="pl-c">// foo.js</span>
<span class="pl-k">import</span> <span class="pl-s1">bar</span> <span class="pl-k">from</span> <span class="pl-s">'./bar'</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">bar</span><span class="pl-kos">)</span></pre></div>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// bar.js
exports.baz = 1"><pre class="notranslate"><span class="pl-c">// bar.js</span>
<span class="pl-s1">exports</span><span class="pl-kos">.</span><span class="pl-c1">baz</span> <span class="pl-c1">=</span> <span class="pl-c1">1</span></pre></div>
<p dir="auto"><code class="notranslate">babel</code> generates the following code for <code class="notranslate">foo.js</code>:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="'use strict';

function _interopRequireDefault(obj) { return obj &amp;&amp; obj.__esModule ? obj : { 'default': obj }; }

var _bar = require('./bar');

var _bar2 = _interopRequireDefault(_bar);

console.log(_bar2['default']);"><pre class="notranslate"><span class="pl-s">'use strict'</span><span class="pl-kos">;</span>

<span class="pl-k">function</span> <span class="pl-en">_interopRequireDefault</span><span class="pl-kos">(</span><span class="pl-s1">obj</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-s1">obj</span> <span class="pl-c1">&amp;&amp;</span> <span class="pl-s1">obj</span><span class="pl-kos">.</span><span class="pl-c1">__esModule</span> ? <span class="pl-s1">obj</span> : <span class="pl-kos">{</span> <span class="pl-s">'default'</span>: <span class="pl-s1">obj</span> <span class="pl-kos">}</span><span class="pl-kos">;</span> <span class="pl-kos">}</span>

<span class="pl-k">var</span> <span class="pl-s1">_bar</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">'./bar'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-k">var</span> <span class="pl-s1">_bar2</span> <span class="pl-c1">=</span> <span class="pl-en">_interopRequireDefault</span><span class="pl-kos">(</span><span class="pl-s1">_bar</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-s1">_bar2</span><span class="pl-kos">[</span><span class="pl-s">'default'</span><span class="pl-kos">]</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Passing the generated code from <code class="notranslate">babel</code> to <code class="notranslate">iojs</code> works fine:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ babel foo.js | iojs
{ baz: 1 }"><pre class="notranslate"><code class="notranslate">$ babel foo.js | iojs
{ baz: 1 }
</code></pre></div>
<p dir="auto">If you run the same module by hand at the REPL, or pipe it in, it fails:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ cat foo.js | babel-node
&gt; import bar from './bar'
'use strict'
&gt; console.log(bar)
repl:3
console.log(bar);
            ^
ReferenceError: bar is not defined
    at repl:3:13
    at Object.exports.runInThisContext (vm.js:54:17)
    at _eval (/home/tomxtobin/npm/lib/node_modules/babel/bin/_babel-node:54:13)
    at REPLServer.replEval (/home/tomxtobin/npm/lib/node_modules/babel/bin/_babel-node:136:14)
    at bound (domain.js:254:14)
    at REPLServer.runBound [as eval] (domain.js:267:12)
    at REPLServer.&lt;anonymous&gt; (repl.js:309:12)
    at emitOne (events.js:77:13)
    at REPLServer.emit (events.js:166:7)
    at REPLServer.Interface._onLine (readline.js:208:10)"><pre class="notranslate"><code class="notranslate">$ cat foo.js | babel-node
&gt; import bar from './bar'
'use strict'
&gt; console.log(bar)
repl:3
console.log(bar);
            ^
ReferenceError: bar is not defined
    at repl:3:13
    at Object.exports.runInThisContext (vm.js:54:17)
    at _eval (/home/tomxtobin/npm/lib/node_modules/babel/bin/_babel-node:54:13)
    at REPLServer.replEval (/home/tomxtobin/npm/lib/node_modules/babel/bin/_babel-node:136:14)
    at bound (domain.js:254:14)
    at REPLServer.runBound [as eval] (domain.js:267:12)
    at REPLServer.&lt;anonymous&gt; (repl.js:309:12)
    at emitOne (events.js:77:13)
    at REPLServer.emit (events.js:166:7)
    at REPLServer.Interface._onLine (readline.js:208:10)
</code></pre></div>
<p dir="auto">But if you pass the file as an argument to <code class="notranslate">babel-node</code> it works fine:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ babel-node foo.js
{ bar: 1 }"><pre class="notranslate"><code class="notranslate">$ babel-node foo.js
{ bar: 1 }
</code></pre></div>
<p dir="auto">If you keep everything in the REPL on the same line, it also works fine:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt; import bar from './bar'; console.log(bar)
{ baz: 1 }
undefined"><pre class="notranslate"><code class="notranslate">&gt; import bar from './bar'; console.log(bar)
{ baz: 1 }
undefined
</code></pre></div>
<p dir="auto">Versions:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ babel --version
5.2.16
$ iojs --version
v2.0.0"><pre class="notranslate"><code class="notranslate">$ babel --version
5.2.16
$ iojs --version
v2.0.0
</code></pre></div>