Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Requires Babel "^7.0.0-0", but was loaded with "6.26.3". If you are sure you have a compatible version of @babel/core, #11337

Closed
houchaowei opened this issue Mar 26, 2020 · 7 comments
Labels
i: question outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@houchaowei
Copy link

Bug Report

After upgrading to babel7.0 from babel6.0 according to https://github.com/babel/babel-upgrade, I got an error, error output:

/Users/resource/BeiKe/pikachu-static-front-owner/node_modules/@babel/helper-plugin-utils/lib/index.js:72
  throw Object.assign(err, {
  ^

Error: Requires Babel "^7.0.0-0", but was loaded with "6.26.3". If you are sure you have a compatible version of @babel/core, it is likely that something in your build process is loading the wrong version. Inspect the stack trace of this error to look for the first entry that doesn't mention "@babel/core" or "babel-core" to see what is calling Babel.
    at throwVersionError (/Users/resource/BeiKe/pikachu-static-front-owner/node_modules/@babel/helper-plugin-utils/lib/index.js:65:11)
    at Object.assertVersion (/Users/resource/BeiKe/pikachu-static-front-owner/node_modules/@babel/helper-plugin-utils/lib/index.js:13:11)
    at _default (/Users/resource/BeiKe/pikachu-static-front-owner/node_modules/@babel/plugin-transform-runtime/lib/index.js:46:7)
    at /Users/resource/BeiKe/pikachu-static-front-owner/node_modules/@babel/helper-plugin-utils/lib/index.js:19:12
    at Function.memoisePluginContainer (/Users/resource/BeiKe/pikachu-static-front-owner/node_modules/babel-register/node_modules/babel-core/lib/transformation/file/options/option-manager.js:113:13)
    at Function.normalisePlugin (/Users/resource/BeiKe/pikachu-static-front-owner/node_modules/babel-register/node_modules/babel-core/lib/transformation/file/options/option-manager.js:146:32)
    at /Users/resource/BeiKe/pikachu-static-front-owner/node_modules/babel-register/node_modules/babel-core/lib/transformation/file/options/option-manager.js:184:30
    at Array.map (<anonymous>)
    at Function.normalisePlugins (/Users/resource/BeiKe/pikachu-static-front-owner/node_modules/babel-register/node_modules/babel-core/lib/transformation/file/options/option-manager.js:158:20)
    at OptionManager.mergeOptions (/Users/resource/BeiKe/pikachu-static-front-owner/node_modules/babel-register/node_modules/babel-core/lib/transformation/file/options/option-manager.js:234:36)
    at OptionManager.init (/Users/resource/BeiKe/pikachu-static-front-owner/node_modules/babel-register/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
    at compile (/Users/resource/BeiKe/pikachu-static-front-owner/node_modules/babel-register/lib/node.js:103:45)
    at loader (/Users/resource/BeiKe/pikachu-static-front-owner/node_modules/babel-register/lib/node.js:144:14)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/resource/BeiKe/pikachu-static-front-owner/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at WEBPACK_OPTIONS (/Users/resource/BeiKe/pikachu-static-front-owner/node_modules/webpack-cli/bin/convert-argv.js:133:13)
    at requireConfig (/Users/resource/BeiKe/pikachu-static-front-owner/node_modules/webpack-cli/bin/convert-argv.js:135:6)
    at /Users/resource/BeiKe/pikachu-static-front-owner/node_modules/webpack-cli/bin/convert-argv.js:142:17
    at Array.forEach (<anonymous>)
    at module.exports (/Users/resource/BeiKe/pikachu-static-front-owner/node_modules/webpack-cli/bin/convert-argv.js:140:15)
    at Object.<anonymous> (/Users/resource/BeiKe/pikachu-static-front-owner/node_modules/webpack-dev-server/bin/webpack-dev-server.js:84:40)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mbloanh5@0.0.1 start: `webpack-dev-server --config ./webpack/webpack.config.dev.babel.js`
npm ERR! Exit status 1

Current Behavior

My package.json:


"dependencies": {

 "antd-mobile": "^2.2.11",

 "axios": "^0.18.0",

 "child\_process": "^1.0.2",

 "classnames": "^2.2.6",

 "eslint-friendly-formatter": "^4.0.1",

 "fastclick": "^1.0.6",

 "glue-redux": "1.1.8",

 "history": "^4.7.2",

 "js-pinyin": "^0.1.9",

 "lodash": "^4.17.10",

 "node-schedule": "^1.3.2",

 "prettier": "^1.14.0",

 "progress": "^2.0.3",

 "prop-types": "^15.6.2",

 "react": "^16.4.1",

 "react-dom": "^16.4.1",

 "react-loadable": "^5.4.0",

 "react-redux": "^5.0.7",

 "react-router": "^4.3.1",

 "react-router-dom": "^4.3.1",

 "react-router-redux": "^5.0.0-alpha.9",

 "react-sticky": "^6.0.3",

 "redux": "^3.5.2",

 "redux-thunk": "^2.3.0",

 "weixin-js-sdk": "^1.4.0-test"

 },

 "devDependencies": {

 "@babel/cli": "^7.0.0",

 "@babel/core": "^7.0.0",

 "babel-core": "7.0.0-bridge.0",

 "@babel/plugin-proposal-class-properties": "^7.0.0",

 "@babel/plugin-proposal-object-rest-spread": "^7.0.0",

 "@babel/plugin-syntax-dynamic-import": "^7.0.0",

 "@babel/plugin-transform-member-expression-literals": "^7.0.0",

 "@babel/plugin-transform-property-literals": "^7.0.0",

 "@babel/plugin-transform-runtime": "^7.0.0",

 "@babel/polyfill": "^7.0.0",

 "@babel/preset-env": "^7.0.0",

 "@babel/preset-react": "^7.0.0",

 "@babel/runtime-corejs2": "^7.0.0",

 "autoprefixer": "^7.1.1",

 "babel-eslint": "^9.0.0",

 "babel-loader": "^8.0.0",

 "babel-plugin-import": "^1.12.0",

 "clean-webpack-plugin": "^0.1.19",

 "copy-webpack-plugin": "^5.0.3",

 "css-loader": "^0.28.11",

 "eslint": "^4.19.1",

 "eslint-config-standard": "^12.0.0",

 "eslint-config-standard-react": "^7.0.2",

 "eslint-loader": "^2.0.0",

 "eslint-plugin-flowtype": "^3.2.0",

 "eslint-plugin-import": "^2.17.2",

 "eslint-plugin-jsx-a11y": "^6.0.3",

 "eslint-plugin-node": "^9.1.0",

 "eslint-plugin-promise": "^4.1.1",

 "eslint-plugin-react": "^7.13.0",

 "eslint-plugin-standard": "^4.0.0",

 "file-loader": "^1.1.11",

 "html-webpack-plugin": "^3.2.0",

 "less": "^3.0.4",

 "less-loader": "^4.1.0",

 "mini-css-extract-plugin": "^0.4.1",

 "optimize-css-assets-webpack-plugin": "^3.2.0",

 "postcss-flexbugs-fixes": "^3.3.1",

 "postcss-loader": "^2.1.5",

 "px2rem-loader": "^0.1.9",

 "redux-devtools": "^3.4.1",

 "redux-devtools-dock-monitor": "^1.1.3",

 "redux-devtools-log-monitor": "^1.4.0",

 "source-map-loader": "^0.2.3",

 "style-loader": "^0.21.0",

 "svg-inline-loader": "^0.8.0",

 "uglifyjs-webpack-plugin": "^1.2.7",

 "url-loader": "^1.0.1",

 "vconsole": "^3.3.0",

 "webpack": "4.15.0",

 "webpack-bundle-analyzer": "^3.3.2",

 "webpack-cli": "^2.0.4",

 "webpack-dev-server": "^3.1.4",

 "webpack-manifest-plugin": "^2.0.3"

 }

Input Code
None

Expected behavior/code
None

Environment

  • Babel version(s): 7.4.5
  • Node/npm version: v8.16.0
  • OS: MacOs

Possible Solution
None

Additional context/Screenshots
None

then i fond an issues: 10108,
but when run

npx nls why babel-core 

output:

npx: 28 安装成功,用时 11.013 秒

nothing else.

How do I update babel-core@6.26.3 to babel-core@7.0.0?

and i dont know what should i do ?

@babel-bot
Copy link
Collaborator

Hey @houchaowei! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite."

@zjffun
Copy link

zjffun commented Mar 26, 2020

I reporduced you steps and get

$ npx nls why babel-core
npx: 28 安装成功,用时 5.482 秒

  Who required babel-core:

  babel-fix > babel-core@7.0.0-bridge.0
  babel-fix > webpack-cli > jscodeshift > babel-register > babel-core@^6.26.0
  babel-fix > webpack-cli > webpack-addons > jscodeshift > babel-register > babel-core@^6.26.0

after update webpack-cli with yarn add webpack-cli :

$ npx nls why babel-core
npx: 28 安装成功,用时 5.213 秒

  Who required babel-core:

  babel-fix > babel-core@7.0.0-bridge.0

@nicolo-ribaudo
Copy link
Member

Yes, the problem probably caused by webpack-cli v2 which depends on Babel 6, and uses it in a way that it loads a Babel 7 plugin from your config.

@houchaowei
Copy link
Author

@zjffun i follow what you said and run:

yarn add webpack-cli

when i run npm run start, it worked but failed to compile.
output:

ERROR in ./client/index.jsx
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: [BABEL] /Users/resource/BeiKe/pikachu-static-front-owner/client/index.jsx: The 'polyfill' option has been removed. Use the 'corejs'option to polyfill with `core-js` via @babel/runtime. (While processing: "/Users/resource/BeiKe/pikachu-static-front-owner/node_modules/@babel/plugin-transform-runtime/lib/index.js")
    at _default (/Users/resource/BeiKe/pikachu-static-front-owner/node_modules/@babel/plugin-transform-runtime/lib/index.js:144:13)
    at /Users/resource/BeiKe/pikachu-static-front-owner/node_modules/@babel/helper-plugin-utils/lib/index.js:19:12
    at /Users/resource/BeiKe/pikachu-static-front-owner/node_modules/@babel/core/lib/config/full.js:199:14
    at Generator.next (<anonymous>)
    at Function.<anonymous> (/Users/resource/BeiKe/pikachu-static-front-owner/node_modules/@babel/core/lib/gensync-utils/async.js:26:3)
    at Generator.next (<anonymous>)
    at step (/Users/resource/BeiKe/pikachu-static-front-owner/node_modules/gensync/index.js:254:32)
    at evaluateAsync (/Users/resource/BeiKe/pikachu-static-front-owner/node_modules/gensync/index.js:284:5)
    at Function.errback (/Users/resource/BeiKe/pikachu-static-front-owner/node_modules/gensync/index.js:108:7)
    at errback (/Users/resource/BeiKe/pikachu-static-front-owner/node_modules/@babel/core/lib/gensync-utils/async.js:70:18)
    at async (/Users/resource/BeiKe/pikachu-static-front-owner/node_modules/gensync/index.js:183:31)
    at onFirstPause (/Users/resource/BeiKe/pikachu-static-front-owner/node_modules/gensync/index.js:209:13)
    at Generator.next (<anonymous>)
    at cachedFunction (/Users/resource/BeiKe/pikachu-static-front-owner/node_modules/@babel/core/lib/config/caching.js:68:46)
    at cachedFunction.next (<anonymous>)
    at loadPluginDescriptor (/Users/resource/BeiKe/pikachu-static-front-owner/node_modules/@babel/core/lib/config/full.js:235:43)
ℹ 「wdm」: Failed to compile.

my ./client/index.js:

import React from 'react';
import { render } from 'react-dom';
import { combineReducers } from 'redux';
import Root from './topContainer/Root/index';
import App from './app';
import reducers from './reducers';
import store, { history } from './store';

import './utils/style'; // 导入 antd 部分组件样式
import './common/styles/common.less';

console.log('JENKINS_ENV = ' + process.env.JENKINS_ENV);

const LoadingMask = document.getElementById('default-mask');
document.body.removeChild(LoadingMask);

// 添加 VConsole
if (process.env.JENKINS_ENV === 'dev') { // v1.4.6测试环境隐藏VConsole
  const VConsole = require('vconsole/dist/vconsole.min.js');
  const vConsole = new VConsole();
  vConsole.setOption({ maxLogNumber: 5000 });
}

store.replaceReducer(combineReducers(reducers));
render(
  <Root store={store} history={history} component={App} />,
  document.getElementById('bd')
);

This is a question of corejs or something else?

@houchaowei
Copy link
Author

my .bablerc:

{
  "presets": [
    "@babel/preset-react",
    [
      "@babel/preset-env",
      {
        "useBuiltIns": "usage",
        "corejs": 3,
        "targets": {
          "chrome": 48,
          "ie": 9,
          "browsers": [
            "> 1%",
            "last 5 versions"
          ]
        }
      }
    ]
  ],
  "plugins": [
    [
      "@babel/plugin-transform-runtime",
      {
        "corejs": 2,
        "helpers": true,
        "polyfill": true,
        "regenerator": true,
        "moduleName": "babel-runtime"
      }
    ],
    "@babel/plugin-proposal-class-properties",
    "@babel/plugin-syntax-dynamic-import",
    "@babel/plugin-proposal-object-rest-spread"
  ]
}

@nicolo-ribaudo
Copy link
Member

Remove the polyfill option from @babel/plugin-transform-runtime.

@houchaowei
Copy link
Author

@nicolo-ribaudo tks! follow your words, it works.

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jun 27, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: question outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

No branches or pull requests

4 participants