Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
986 views
in Technique[技术] by (71.8m points)

reactjs - Requires Babel "7.0.0-0" but was loaded with "6.26.3"

Keep getting this error no matter what I tried installing (babel wise) as I follow other similar reports. this is the stack trace:

error: bundling failed: 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. (While processing preset:
"C:\Users\Admin-ESS\Absent\node_modules\@babel\preset-env\lib\index.js")
    at throwVersionError (C:UsersAdmin-ESSAbsent
ode_modules@babelpreset-env
[email protected]:65:11)
    at Object.assertVersion (C:UsersAdmin-ESSAbsent
ode_modules@babelpreset-env
[email protected]:13:11)
    at _default (C:UsersAdmin-ESSAbsent
[email protected]:150:7)
    at C:UsersAdmin-ESSAbsent
ode_modules@babelpreset-env
[email protected]:19:12
    at C:UsersAdmin-ESSAbsent
ode_modulesmetro
ode_modulesabel-corelibransformationfileoptionsoption-manager.js:317:46
    at Array.map (<anonymous>)
    at OptionManager.resolvePresets (C:UsersAdmin-ESSAbsent
ode_modulesmetro
ode_modulesabel-corelibransformationfileoptionsoption-manager.js:275:20)
    at OptionManager.mergePresets (C:UsersAdmin-ESSAbsent
ode_modulesmetro
ode_modulesabel-corelibransformationfileoptionsoption-manager.js:264:10)
    at OptionManager.mergeOptions (C:UsersAdmin-ESSAbsent
ode_modulesmetro
ode_modulesabel-corelibransformationfileoptionsoption-manager.js:249:14)
    at OptionManager.init (C:UsersAdmin-ESSAbsent
ode_modulesmetro
ode_modulesabel-corelibransformationfileoptionsoption-manager.js:368:12)
    at File.initOptions (C:UsersAdmin-ESSAbsent
ode_modulesmetro
ode_modulesabel-corelibransformationfileindex.js:212:65)
    at new File (C:UsersAdmin-ESSAbsent
ode_modulesmetro
ode_modulesabel-corelibransformationfileindex.js:135:24)
    at Pipeline.transform (C:UsersAdmin-ESSAbsent
ode_modulesmetro
ode_modulesabel-corelibransformationpipeline.js:46:16)
    at Object.transform (C:UsersAdmin-ESSAbsent
ode_modulesmetrosrcransformer.js:135:5)
    at Object.transformCode [as transform] (C:UsersAdmin-ESSAbsent
ode_modulesmetrosrcJSTransformerworkerindex.js:253:15)
    at execMethod (C:UsersAdmin-ESSAbsent
ode_modulesjest-workeruildchild.js:92:29)
    at process.on (C:UsersAdmin-ESSAbsent
ode_modulesjest-workeruildchild.js:42:7)
    at process.emit (events.js:180:13)
    at emit (internal/child_process.js:783:12)

and my package.json:

{
  "name": "Absent",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "babel-preset-react-native-stage-0": "^1.0.1",
    "jest": "^23.5.0",
    "jest-react-native": "^18.0.0",
    "react-test-renderer": "16.3.1"
  },
  "scripts": {
    "start": "react-native start",
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "test": "jest"
  },
  "jest": {
    "preset": "react-native"
  },
  "dependencies": {
    "@babel/core": "^7.0.0-rc.1",
    "@babel/preset-env": "^7.0.0-rc.1",
    "@babel/preset-react": "^7.0.0-rc.1",
    "jail-monkey": "^1.0.0",
    "prop-types": "^15.6.2",
    "react": "16.3.1",
    "react-native": "^0.55.4",
    "react-native-device-info": "^0.22.4",
    "react-native-elements": "^0.19.1",
    "react-native-firebase": "^4.3.8",
    "react-native-modal": "^6.5.0",
    "react-native-router-flux": "^4.0.1",
    "react-native-size-matters": "^0.1.2",
    "react-native-vector-icons": "^5.0.0",
    "react-redux": "^5.0.7",
    "redux": "^4.0.0",
    "redux-thunk": "^2.3.0"
  },
  "rnpm": {
    "assets": [
      "./assets/fonts/"
    ]
  }
}

Any pointers would be greatly appreciated here...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Test which version you are running with cmd

babel -V

If it is not verion 7 or higher

npm uninstall babel-cli -g
npm uninstall babel-core -g

And

npm install @babel/cli -g
npm install @babel/core -g

If you are using Jest run

npm install [email protected] --save-dev

Uninstall and reinstall @babel/node solves the problem if you do node development.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...