This is my directory structure:
├───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
In demo/entry/index.js
I have
import tap from '../../src/tap';
When compiling this, babel throws error
ERROR in ../src/tap.js
Module build failed: Error: Cannot find module 'core-js/library/fn/get-iterator'
But it works if I import like this
import tap from './tap';
The file ./tap.js
and ../../src/tap
are the same.
Is the problem node_modules
? Because in demo
directory, the babel and anything else is in node_modules
, so I can import
any file I like. But src/tap.js
has no such parent or sibling directory like node_modules
, so it will trigger this error.
Updating to node version 11.10.0
(Current Version) worked for me.
I just installed core-js and it worked.
Try to install babel-loader and babel-core as dev-dependency:
npm install babel-core babel-loader --save-dev
Also you need to update your .babelrc
{
"presets" : ["es2015", "react"]
}
It works good for me. Good luck ;)
Maybe you did not install core-js. I used to meet this problem.
yarn install
if you had installed yarnIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With