盖茨比失败的生产构建
Gatsby failing production build
最近,Gatsby 开始无法构建站点的生产版本。开发版构建良好。
这似乎是一些 Babel 问题,但我不知道它是什么。我已经升级了所有内容,删除了 node_modules 文件夹和 yarn.lock 但是在重新构建所有内容之后它仍然以同样的方式失败。
我不是特别熟悉 Babel 的内部工作原理,所以我猜这与 Gatsby 附带的 Babel 设置有关?
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)
这是我的 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"
},
不确定这是否有帮助,但我遇到了与此相同的问题并意识到我有一个 package-lock.json
和一个 yarn.lock
文件。我删除了 yarn.lock
文件并修复了错误。
我不确定这是否有助于本地构建,但我今天在 Netlify 上部署时遇到了同样的问题,我已经通过切换到 npm 解决了这个问题。
这是我遵循的步骤:
- 删除了
yarn.lock
和旧的 package-lock.json
- 添加了
yarn.lock
,从 .gitignore
中删除了 package-lock.json
- 删除了
node_modules
个文件夹
- 使用 npm 重新安装依赖项
- 运行 使用 npm 构建命令
最近,Gatsby 开始无法构建站点的生产版本。开发版构建良好。
这似乎是一些 Babel 问题,但我不知道它是什么。我已经升级了所有内容,删除了 node_modules 文件夹和 yarn.lock 但是在重新构建所有内容之后它仍然以同样的方式失败。
我不是特别熟悉 Babel 的内部工作原理,所以我猜这与 Gatsby 附带的 Babel 设置有关?
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)
这是我的 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"
},
不确定这是否有帮助,但我遇到了与此相同的问题并意识到我有一个 package-lock.json
和一个 yarn.lock
文件。我删除了 yarn.lock
文件并修复了错误。
我不确定这是否有助于本地构建,但我今天在 Netlify 上部署时遇到了同样的问题,我已经通过切换到 npm 解决了这个问题。
这是我遵循的步骤:
- 删除了
yarn.lock
和旧的package-lock.json
- 添加了
yarn.lock
,从.gitignore
中删除了 - 删除了
node_modules
个文件夹 - 使用 npm 重新安装依赖项
- 运行 使用 npm 构建命令
package-lock.json