赞
踩
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Plugin/Preset files are not allowed to export objects, only functions.
出现错误是由于babel的版本冲,
有两种解决方式:
版本更换:
1 . babel-loader 8.x | babel 7.x (升级版本)
npm install -D babel-loader @babel/core @babel/preset-env webpack
2 . babel-loader 7.x | babel 6.x (降级版本)
npm install -D babel-loader@7 babel-core babel-preset-env webpack
相关配置修改:
1 . 升级版本,执行命令:
npm install -D babel-loader @babel/core @babel/preset-env @babel/preset-react webpack
更新:
"@babel/core": "^7.7.4",
"@babel/preset-env": "^7.7.4",
"@babel/preset-react": "^7.7.4",
"babel-loader": "^8.0.6",
babel配置修改为:
presets: [
“@babel/env”, “@babel/react”
]
2 . 降级版本,执行命令
npm install -D babel-loader@7 babel-core babel-preset-env babel-preset-react webpack
相关配置降级到6.0版本:
"babel-core": "^6.26.3",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"babel-loader": "^7.1.5",
babel配置修改为 :
presets: [
“env”,“react”
]
npm网址:babel-loader
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。