All Articles

Making Gatsby template and WebpackError: Cannot find module 'core-js/modules/es6.array.iterator'

I’m trying to make a gatsby template. I face WebpackError: Cannot find module 'core-js/modules/es6.array.iterator'.

Hmm. I’m very tired to solve this.

$ node -v
v10.15.3

Inside package.json

  "dependencies": {
    "gatsby": "^2.3.3",
    "gatsby-plugin-google-analytics": "^2.0.18",
    "gatsby-plugin-react-helmet": "^3.0.11",
    "react": "^16.8.5",
    "react-dom": "^16.8.5",
    "react-helmet": "^5.2.0"
  },
    "devDependencies": {
    "@babel/core": "^7.4.0",
    "@babel/preset-env": "^7.4.2",
    "@babel/preset-react": "^7.0.0",
    "babel-loader": "^8.0.5",
    "eslint": "^5.15.3",
    "eslint-plugin-react": "^7.12.4",
    "webpack": "^4.29.6",
    "webpack-cli": "^3.3.0"
  }

Inside core-js

$ ls node_modules/core-js/modules
...
es.array.iterator.js
...

There is a es.array.iterator.js not a es6.array.iterator.js

Who call es6?

I don’t know. I cannot find.

However the reason why this error occur is found.

My mistake

My mistake is

$ npm install --save-dev @babel/preset-env

Because of this command, the version of core-js become 3.x but required is 2.x .

2.x and 3.x of core-js is different.