<p dir="auto">In the Babel repl, imported modules are available on the same line of code as the <code class="notranslate">import</code> statement, but the reference is lost on subsequent lines:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt; import route from './src/route'; typeof route === 'object'
true
&gt; typeof route === 'object'
false"><pre class="notranslate"><span class="pl-c1">&gt;</span> <span class="pl-k">import</span> <span class="pl-s1">route</span> <span class="pl-k">from</span> <span class="pl-s">'./src/route'</span><span class="pl-kos">;</span> <span class="pl-k">typeof</span> <span class="pl-s1">route</span> <span class="pl-c1">===</span> <span class="pl-s">'object'</span>
<span class="pl-c1">true</span>
<span class="pl-c1">&gt;</span> <span class="pl-k">typeof</span> <span class="pl-s1">route</span> <span class="pl-c1">===</span> <span class="pl-s">'object'</span>
<span class="pl-c1">false</span></pre></div>
<p dir="auto">This problem doesn't take placing when <code class="notranslate">require</code>ing a module.<br>
A workaround is to assign the module to a variable on the same line, or use <code class="notranslate">require</code>.</p>
<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>