webpack版本要与babel版本对应,否则即使配置项exclude配置了node_modules也可能会报错。babel配置详见GitHub地址
webpack 4.x | babel-loader 8.x | babel 7.x
对应指令
npm install -D babel-loader @babel/core @babel/preset-env webpack
webpack 1.x | babel-loader <= 6.x
webpack 2.x | babel-loader >= 7.x (recommended) (^6.2.10 will also work, but with deprecation warnings)
webpack 3.x | babel-loader >= 7.1
npm install --save-dev babel-loader babel-core babel-preset-env webpack