您的构建过程中正在加载错误的版本

时间:2019-01-28 11:08:13

标签: reactjs babeljs

我遇到以下错误。无法解决。我发现许多帖子看起来在这里重复,但是没有用。

like:Requires Babel "7.0.0-0" but was loaded with "6.26.3"

  

node_modules @ babel \ helper-plugin-utils \ lib \ index.js

     

抛出Object.assign(err,{

     

错误:需要Babel“ ^ 7.0.0-0”,但已加载“ 6.26.3”。如果您确定拥有@ babel / core的兼容版本,则可能是您的构建过程中正在加载错误的版本。检查此错误的堆栈跟踪,以查找第一个未提及“ @ babel / core”或“ babel-core”的条目   什么叫通天塔。

以下是我的class MainActivity : AppCompatActivity(), View.OnClickListener { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) choose_1_player.setOnClickListener(this) } override fun onClick(v: View) { when (v.id){ R.id.choose_1_player -> println("Hello") R.id.choose_2_player -> println("Hello") } } }

package.json

我要开始npm了。

"dependencies": {
    "express": "^4.16.4",
    "isomorphic-fetch": "^2.2.1",
    "react": "^16.6.3",
    "react-dom": "^16.6.3",
    "react-redux": "^5.1.1",
    "react-router": "^4.3.1",
    "react-router-config": "^1.0.0-beta.4",
    "react-router-dom": "^4.3.1",
    "redux": "^4.0.1",
    "redux-thunk": "^2.3.0"
  },
  "devDependencies": {
    "@babel/cli": "^7.2.3",
    "@babel/core": "^7.2.2",
    "@babel/plugin-proposal-class-properties": "^7.2.0",
    "@babel/plugin-transform-runtime": "^7.2.0",
    "@babel/preset-env": "^7.3.1",
    "@babel/preset-react": "^7.0.0",
    "babel-core": "^7.0.0-bridge.0",
    "babel-jest": "^24.0.0",
    "babel-loader": "^7.1.5",
    "css-loader": "^1.0.1",
    "cypress": "^3.1.3",
    "enzyme": "^3.8.0",
    "enzyme-adapter-react-16": "^1.7.1",
    "enzyme-to-json": "^3.3.5",
    "extract-text-webpack-plugin": "^4.0.0-beta.0",
    "html-webpack-plugin": "^3.2.0",
    "jest": "^24.0.0",
    "jest-fetch-mock": "^2.0.1",
    "json-loader": "^0.5.7",
    "nodemon": "^1.18.9",
    "npm-run-all": "^4.1.5",
    "open": "0.0.5",
    "redux-devtools": "^3.4.2",
    "redux-mock-store": "^1.5.3",
    "regenerator-runtime": "^0.13.1",
    "style-loader": "^0.23.1",
    "uglifyjs-webpack-plugin": "^2.0.1",
    "webpack": "^4.26.1",
    "webpack-cli": "^3.1.2",
    "webpack-dev-server": "^3.1.14",
    "webpack-node-externals": "^1.7.2"
  },
  "babel": {
    "presets": [
      "@babel/preset-env",
      "@babel/preset-react"
    ],
    "plugins": [
      "@babel/plugin-transform-runtime",
      "@babel/plugin-proposal-class-properties"
    ]
  }

1 个答案:

答案 0 :(得分:3)

找到了:-)

我注意到babel-node不在您的依赖范围内,因此您必须使用babel-node的全局版本,可能是版本6 ...因此,只需将正确的版本添加到{{1 }}:

devDependencies