Requires Babel "^7.0.0-0", but was loaded with "6.26.3".

1 篇文章 0 订阅
1 篇文章 0 订阅
babel is a javascript compiler

想通过babel-node让后端node可以运行es6,结果装完babel-cli总是报错Requires Babel “^7.0.0-0”, but was loaded with “6.26.3”.具体如下:
下面是我的package.json文件

{
  "name": "form-react",
  "version": "1.0.0",
  "description": "",
  "main": "webpack.config.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dev": "webpack --mode development",
    "build": "webpack --mode production",
    "start": "webpack-dev-server"
  },
  "dependencies": {
    "babel-loader": "^7.1.5",
    "react": "^16.8.6",
    "react-dom": "^16.8.6"
  },
  "devDependencies": {
    "@babel/core": "^7.4.3",
    "@babel/plugin-proposal-class-properties": "^7.4.0",
    "@babel/preset-react": "^7.0.0",
    "babel-cli": "^6.26.0",
    "babel-loader": "^8.0.5",
    "babel-preset-env": "^1.7.0",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-stage-0": "^6.24.1",
    "css-loader": "^2.1.1",
    "less": "^3.9.0",
    "less-loader": "^4.1.0",
    "resolve": "^1.10.0",
    "style-loader": "^0.23.1"
  },
  "author": "",
  "license": "ISC"
}

终端执行打包,并且webpack已配置热更新,npm run start
报错:报错
原因:babel将前端环境更新到babel7,jest-babel之前是基于babel6的,执行时候就会报:Requires Babel “^7.0.0-0”, but was loaded with “6.26.3”.

解决:cnpm i babel-core@^7.0.0-bridge.0 @babel/core regenerator-runtime
- npm run start
-  Compiled successfully.
  • 7
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值