Recently, Gatsby started failing to build a production version of the site. Development version builds fine.
It seems to be some Babel issue but I can't figure out what it is. I've upgraded everything, deleted the node_modules folder and yarn.lock but after building everything afresh again it fails the same way.
I'm not particularly familiar with the inner workings Babel so I'm guessing this is something to do with the Babel settings shipped with Gatsby?
ERROR #98123 WEBPACK
Generating JavaScript bundles failed
[BABEL] /Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@fortawesome/react-fontawesome/index.es.js: Invalid Option: corejs is not a valid top-level option.
Maybe you meant to use 'targets'? (While processing: "/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/index.js")
File: node_modules/@fortawesome/react-fontawesome/index.es.js
ERROR #98123 WEBPACK
Generating JavaScript bundles failed
[BABEL] /Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@mikaelkristiansson/domready/ready.js: Invalid Option: corejs is not a valid top-level option.
Maybe you meant to use 'targets'? (While processing: "/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/index.js")
File: node_modules/@mikaelkristiansson/domready/ready.js
ERROR #98123 WEBPACK
Generating JavaScript bundles failed
[BABEL] /Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@reach/router/es/index.js: Invalid Option: corejs is not a valid top-level option.
Maybe you meant to use 'targets'? (While processing: "/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/index.js")
File: node_modules/@reach/router/es/index.js
ERROR #98123 WEBPACK
Generating JavaScript bundles failed
[BABEL] /Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@reach/router/es/lib/utils.js: Invalid Option: corejs is not a valid top-level option.
Maybe you meant to use 'targets'? (While processing: "/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/index.js")
File: node_modules/@reach/router/es/lib/utils.js
ERROR #98123 WEBPACK
Generating JavaScript bundles failed
[BABEL] /Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby-link/index.js: Invalid Option: corejs is not a valid top-level option.
Maybe you meant to use 'targets'? (While processing: "/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/index.js")
File: node_modules/gatsby-link/index.js
ERROR #98123 WEBPACK
Generating JavaScript bundles failed
[BABEL] /Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby-react-router-scroll/index.js: Invalid Option: corejs is not a valid top-level option.
Maybe you meant to use 'targets'? (While processing: "/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/index.js")
File: node_modules/gatsby-react-router-scroll/index.js
ERROR #98123 WEBPACK
Generating JavaScript bundles failed
[BABEL] /Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/lodash/lodash.js: Invalid Option: corejs is not a valid top-level option.
Maybe you meant to use 'targets'? (While processing: "/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/index.js")
File: node_modules/lodash/lodash.js
ERROR #98123 WEBPACK
Generating JavaScript bundles failed
[BABEL] /Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/mitt/dist/mitt.es.js: Invalid Option: corejs is not a valid top-level option.
Maybe you meant to use 'targets'? (While processing: "/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/index.js")
File: node_modules/mitt/dist/mitt.es.js
ERROR #98123 WEBPACK
Generating JavaScript bundles failed
[BABEL] /Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/netlify-identity-widget/build/netlify-identity.js: Invalid Option: corejs is not a valid top-level option.
Maybe you meant to use 'targets'? (While processing: "/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/index.js")
File: node_modules/netlify-identity-widget/build/netlify-identity.js
ERROR #98123 WEBPACK
Generating JavaScript bundles failed
[BABEL] /Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/prop-types/index.js: Invalid Option: corejs is not a valid top-level option.
Maybe you meant to use 'targets'? (While processing: "/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/index.js")
File: node_modules/prop-types/index.js
ERROR #98123 WEBPACK
Generating JavaScript bundles failed
[BABEL] /Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/react-add-to-calendar/dist/react-add-to-calendar.min.js: Invalid Option: corejs is not a valid top-level option.
Maybe you meant to use 'targets'? (While processing: "/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/index.js")
File: node_modules/react-add-to-calendar/dist/react-add-to-calendar.min.js
ERROR #98123 WEBPACK
Generating JavaScript bundles failed
[BABEL] /Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/react-dom/index.js: Invalid Option: corejs is not a valid top-level option.
Maybe you meant to use 'targets'? (While processing: "/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/index.js")
File: node_modules/react-dom/index.js
ERROR #98123 WEBPACK
Generating JavaScript bundles failed
[BABEL] /Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/react-helmet/lib/Helmet.js: Invalid Option: corejs is not a valid top-level option.
Maybe you meant to use 'targets'? (While processing: "/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/index.js")
File: node_modules/react-helmet/lib/Helmet.js
ERROR #98123 WEBPACK
Generating JavaScript bundles failed
[BABEL] /Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/react-image-gallery/build/image-gallery.js: Invalid Option: corejs is not a valid top-level option.
Maybe you meant to use 'targets'? (While processing: "/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/index.js")
File: node_modules/react-image-gallery/build/image-gallery.js
ERROR #98123 WEBPACK
Generating JavaScript bundles failed
[BABEL] /Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/react-share/es/index.js: Invalid Option: corejs is not a valid top-level option.
Maybe you meant to use 'targets'? (While processing: "/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/index.js")
File: node_modules/react-share/es/index.js
ERROR #98123 WEBPACK
Generating JavaScript bundles failed
[BABEL] /Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/react/index.js: Invalid Option: corejs is not a valid top-level option.
Maybe you meant to use 'targets'? (While processing: "/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/index.js")
File: node_modules/react/index.js
ERROR #98123 WEBPACK
Generating JavaScript bundles failed
[BABEL] /Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/shallow-compare/es/index.js: Invalid Option: corejs is not a valid top-level option.
Maybe you meant to use 'targets'? (While processing: "/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/index.js")
File: node_modules/shallow-compare/es/index.js
ERROR #98123 WEBPACK
Generating JavaScript bundles failed
Module build failed (from ./node_modules/gatsby/node_modules/babel-loader/lib/index.js):
Error: [BABEL] /Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/css-loader/lib/css-base.js: Invalid Option: corejs is not a valid top-level option.
Maybe you meant to use 'targets'? (While processing: "/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/index.js")
at validateTopLevelOptions (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/normalize-options.js:49:13)
at normalizeOptions (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/normalize-options.js:160:3)
at _default (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/index.js:168:37)
at /Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/helper-plugin-utils/lib/index.js:19:12
at loadDescriptor (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/full.js:165:14)
at cachedFunction (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/caching.js:33:19)
at loadPresetDescriptor (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/full.js:235:63)
at config.presets.reduce (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/full.js:77:21)
at Array.reduce (<anonymous>)
at recurseDescriptors (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/full.js:74:38)
at recurseDescriptors (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/full.js:94:27)
at loadFullConfig (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/full.js:108:6)
at process.nextTick (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/transform.js:28:33)
at process._tickCallback (internal/process/next_tick.js:61:11)
File: src/components/share.scss
ERROR #98123 WEBPACK
Generating JavaScript bundles failed
Module build failed (from ./node_modules/gatsby/node_modules/babel-loader/lib/index.js):
Error: [BABEL] /Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/css-loader/lib/css-base.js: Invalid Option: corejs is not a valid top-level option.
Maybe you meant to use 'targets'? (While processing: "/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/index.js")
at validateTopLevelOptions (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/normalize-options.js:49:13)
at normalizeOptions (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/normalize-options.js:160:3)
at _default (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/index.js:168:37)
at /Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/helper-plugin-utils/lib/index.js:19:12
at loadDescriptor (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/full.js:165:14)
at cachedFunction (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/caching.js:33:19)
at loadPresetDescriptor (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/full.js:235:63)
at config.presets.reduce (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/full.js:77:21)
at Array.reduce (<anonymous>)
at recurseDescriptors (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/full.js:74:38)
at recurseDescriptors (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/full.js:94:27)
at loadFullConfig (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/full.js:108:6)
at process.nextTick (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/transform.js:28:33)
at process._tickCallback (internal/process/next_tick.js:61:11)
File: node_modules/react-add-to-calendar/dist/react-add-to-calendar.css
ERROR #98123 WEBPACK
Generating JavaScript bundles failed
Module build failed (from ./node_modules/gatsby/node_modules/babel-loader/lib/index.js):
Error: [BABEL] /Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/css-loader/lib/css-base.js: Invalid Option: corejs is not a valid top-level option.
Maybe you meant to use 'targets'? (While processing: "/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/index.js")
at validateTopLevelOptions (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/normalize-options.js:49:13)
at normalizeOptions (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/normalize-options.js:160:3)
at _default (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/index.js:168:37)
at /Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/helper-plugin-utils/lib/index.js:19:12
at loadDescriptor (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/full.js:165:14)
at cachedFunction (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/caching.js:33:19)
at loadPresetDescriptor (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/full.js:235:63)
at config.presets.reduce (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/full.js:77:21)
at Array.reduce (<anonymous>)
at recurseDescriptors (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/full.js:74:38)
at recurseDescriptors (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/full.js:94:27)
at loadFullConfig (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/full.js:108:6)
at process.nextTick (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/transform.js:28:33)
at process._tickCallback (internal/process/next_tick.js:61:11)
File: node_modules/react-image-gallery/styles/css/image-gallery.css
ERROR #98123 WEBPACK
Generating JavaScript bundles failed
Module build failed (from ./node_modules/gatsby/node_modules/babel-loader/lib/index.js):
Error: [BABEL] /Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/css-loader/lib/css-base.js: Invalid Option: corejs is not a valid top-level option.
Maybe you meant to use 'targets'? (While processing: "/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/index.js")
at validateTopLevelOptions (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/normalize-options.js:49:13)
at normalizeOptions (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/normalize-options.js:160:3)
at _default (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/index.js:168:37)
at /Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/helper-plugin-utils/lib/index.js:19:12
at loadDescriptor (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/full.js:165:14)
at cachedFunction (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/caching.js:33:19)
at loadPresetDescriptor (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/full.js:235:63)
at config.presets.reduce (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/full.js:77:21)
at Array.reduce (<anonymous>)
at recurseDescriptors (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/full.js:74:38)
at recurseDescriptors (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/full.js:94:27)
at loadFullConfig (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/full.js:108:6)
at process.nextTick (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/transform.js:28:33)
at process._tickCallback (internal/process/next_tick.js:61:11)
File: src/templates/gallery.css
ERROR #98123 WEBPACK
Generating JavaScript bundles failed
Module build failed (from ./node_modules/gatsby/node_modules/babel-loader/lib/index.js):
Error: [BABEL] /Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/css-loader/lib/css-base.js: Invalid Option: corejs is not a valid top-level option.
Maybe you meant to use 'targets'? (While processing: "/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/index.js")
at validateTopLevelOptions (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/normalize-options.js:49:13)
at normalizeOptions (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/normalize-options.js:160:3)
at _default (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/preset-env/lib/index.js:168:37)
at /Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/@babel/helper-plugin-utils/lib/index.js:19:12
at loadDescriptor (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/full.js:165:14)
at cachedFunction (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/caching.js:33:19)
at loadPresetDescriptor (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/full.js:235:63)
at config.presets.reduce (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/full.js:77:21)
at Array.reduce (<anonymous>)
at recurseDescriptors (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/full.js:74:38)
at recurseDescriptors (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/full.js:94:27)
at loadFullConfig (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/config/full.js:108:6)
at process.nextTick (/Users/carlosbeneto/Documents/JS/lonely-lentil-site/node_modules/gatsby/node_modules/@babel/core/lib/transform.js:28:33)
at process._tickCallback (internal/process/next_tick.js:61:11)
Here's my package.json:
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.19",
"@fortawesome/free-solid-svg-icons": "^5.9.0",
"@fortawesome/react-fontawesome": "^0.1.4",
"bulma": "^0.7.5",
"core-js": "2",
"gatsby": "^2.13.31",
"gatsby-image": "^2.2.6",
"gatsby-plugin-google-analytics": "^2.1.4",
"gatsby-plugin-netlify": "^2.1.3",
"gatsby-plugin-netlify-cms": "^4.1.6",
"gatsby-plugin-netlify-cms-paths": "^1.2.2",
"gatsby-plugin-purgecss": "^3.1.1",
"gatsby-plugin-react-helmet": "^3.1.2",
"gatsby-plugin-sass": "^2.1.3",
"gatsby-plugin-sharp": "^2.2.8",
"gatsby-plugin-sitemap": "^2.2.3",
"gatsby-remark-copy-linked-files": "^2.1.3",
"gatsby-remark-images": "^3.1.6",
"gatsby-remark-relative-images": "^0.2.2",
"gatsby-source-filesystem": "^2.1.5",
"gatsby-transformer-remark": "^2.6.7",
"gatsby-transformer-sharp": "^2.2.4",
"lodash": "^4.17.15",
"lodash-webpack-plugin": "^0.11.4",
"netlify-cms-app": "^2.9.6",
"node-sass": "^4.12.0",
"parcel-bundler": "^1.12.3",
"prop-types": "^15.6.0",
"react": "^16.8.6",
"react-add-to-calendar": "^0.1.5",
"react-dom": "^16.8.6",
"react-facebook": "^7.0.6",
"react-helmet": "^5.2.1",
"react-image-gallery": "^0.8.18",
"react-share": "^2.4.0",
"uuid": "^3.2.1"
},
I'm not sure if this can help for local builds, but I had the same issue when deploying on Netlify today and I have been able to solve the issue by switching to npm.
Here is the steps I followed:
yarn.lock
and old package-lock.json
yarn.lock
, removed package-lock.json
from .gitignore
node_modules
folder