webpack编译报错信息
Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: Cannot find module '@babel/core' babel-loader@8 requires Babel 7.x (the package '@babel/core'). If you'd like to use Babel 6.x ('babel-core'), you should install 'babel-loader@7'.
原因
- babel-loader和babel-core版本不对应所产生的,
- babel-loader 8.x对应babel-core 7.x
- babel-loader 7.x对应babel-core 6.x
解决方法
-
回退低版本
npm install -D babel-loader@7 babel-core babel-preset-env
-
更新到最高版本:
npm install -D babel-loader @babel/core @babel/preset-env webpack