<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>
<p dir="auto">This used to work for me in 4.x, but since updating it doesn't seem like import works interactively any more.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[chris /tmp/aaa]$ npm i kefir
kefir@1.3.1 node_modules/kefir
[chris /tmp/aaa]$ babel-node --version
5.1.9
[chris /tmp/aaa]$ babel-node
&gt; import Kefir from 'kefir';
'use strict'
&gt; Kefir
ReferenceError: Kefir is not defined
    at [object Object]:3:1
    at _eval (/usr/local/lib/node_modules/babel/bin/_babel-node:54:13)
    at REPLServer.replEval [as eval] (/usr/local/lib/node_modules/babel/bin/_babel-node:136:14)
    at Interface.&lt;anonymous&gt; (repl.js:239:12)
    at Interface.emit (events.js:95:17)
    at Interface._onLine (readline.js:203:10)
    at Interface._line (readline.js:532:8)
    at Interface._ttyWrite (readline.js:761:14)
    at ReadStream.onkeypress (readline.js:100:10)
    at ReadStream.emit (events.js:98:17)
&gt; [chris /tmp/aaa]$ 
[chris /tmp/aaa]$ echo &quot;import Kefir from 'kefir'; console.log(Kefir);&quot;|babel-node
&gt; import Kefir from 'kefir'; console.log(Kefir);
{ DEPRECATION_WARNINGS: true,
  Observable: [Function: Observable],
  Stream: [Function: Stream],
  Property: [Function: Property],
  withInterval: [Function],
  fromPoll: [Function],
  interval: [Function],
  sequentially: [Function],
  repeatedly: [Function],
  later: [Function],
  merge: [Function],
  concat: [Function],
  Pool: [Function: Pool],
  pool: [Function],
  Bus: [Function: Bus],
  bus: [Function],
  zip: [Function],
  combine: [Function],
  sampledBy: [Function],
  fromBinder: [Function],
  emitter: [Function],
  Emitter: [Function: Emitter],
  never: [Function],
  constant: [Function],
  constantError: [Function],
  repeat: [Function],
  and: [Function],
  or: [Function],
  fromCallback: [Function],
  fromNodeCallback: [Function],
  fromPromise: [Function],
  fromSubUnsub: [Function],
  fromEvent: [Function],
  Kefir: [Circular] }
undefined
&gt; [chris /tmp/aaa]$ "><pre class="notranslate"><code class="notranslate">[chris /tmp/aaa]$ npm i kefir
kefir@1.3.1 node_modules/kefir
[chris /tmp/aaa]$ babel-node --version
5.1.9
[chris /tmp/aaa]$ babel-node
&gt; import Kefir from 'kefir';
'use strict'
&gt; Kefir
ReferenceError: Kefir is not defined
    at [object Object]:3:1
    at _eval (/usr/local/lib/node_modules/babel/bin/_babel-node:54:13)
    at REPLServer.replEval [as eval] (/usr/local/lib/node_modules/babel/bin/_babel-node:136:14)
    at Interface.&lt;anonymous&gt; (repl.js:239:12)
    at Interface.emit (events.js:95:17)
    at Interface._onLine (readline.js:203:10)
    at Interface._line (readline.js:532:8)
    at Interface._ttyWrite (readline.js:761:14)
    at ReadStream.onkeypress (readline.js:100:10)
    at ReadStream.emit (events.js:98:17)
&gt; [chris /tmp/aaa]$ 
[chris /tmp/aaa]$ echo "import Kefir from 'kefir'; console.log(Kefir);"|babel-node
&gt; import Kefir from 'kefir'; console.log(Kefir);
{ DEPRECATION_WARNINGS: true,
  Observable: [Function: Observable],
  Stream: [Function: Stream],
  Property: [Function: Property],
  withInterval: [Function],
  fromPoll: [Function],
  interval: [Function],
  sequentially: [Function],
  repeatedly: [Function],
  later: [Function],
  merge: [Function],
  concat: [Function],
  Pool: [Function: Pool],
  pool: [Function],
  Bus: [Function: Bus],
  bus: [Function],
  zip: [Function],
  combine: [Function],
  sampledBy: [Function],
  fromBinder: [Function],
  emitter: [Function],
  Emitter: [Function: Emitter],
  never: [Function],
  constant: [Function],
  constantError: [Function],
  repeat: [Function],
  and: [Function],
  or: [Function],
  fromCallback: [Function],
  fromNodeCallback: [Function],
  fromPromise: [Function],
  fromSubUnsub: [Function],
  fromEvent: [Function],
  Kefir: [Circular] }
undefined
&gt; [chris /tmp/aaa]$ 
</code></pre></div>