Babel compile error: Cannot find module core-js/library/fn/get-iterator
<p>This is my directory structure:</p>

<pre><code>├───demo
│   ├───entry
│   │   ├───index.js
│   │   ├───tap.js
│   │   └───util.js
│   ├───node_modules
│   ├───index.html
│   ├───package.json
│   └───webpack.config.js
├───src
│   ├───tap.js
│   └───util.js
├───index.js
└───package.json
</code></pre>

<p>In <code>demo/entry/index.js</code> I have </p>

<pre><code>import tap from '../../src/tap';
</code></pre>

<p>When compiling this, babel throws error </p>

<pre><code>ERROR in ../src/tap.js
Module build failed: Error: Cannot find module 'core-js/library/fn/get-iterator'
</code></pre>

<p>But it works if I import like this </p>

<pre><code>import tap from './tap';
</code></pre>

<p>The file <code>./tap.js</code> and <code>../../src/tap</code> are the same.</p>

<p>Is the problem <code>node_modules</code>? Because in <code>demo</code> directory, the babel and anything else is in <code>node_modules</code>, so I can <code>import</code> any file I like. But <code>src/tap.js</code> has no such parent or sibling directory like <code>node_modules</code>, so it will trigger this error.</p>