Module build failed: Error: Plugin/Preset files are not allowed to export objects, only functions.


运行项目是提示Module build failed: Error: Plugin/Preset files are not allowed to export objects, only functions.

原来是babel版本兼容问题

在这里插入图片描述

修改为

  "devDependencies": {
    "babel-core": "^6.26.0",
    "babel-eslint": "7.2.3",
    "babel-loader": "^7.1.2",
    "babel-plugin-transform-decorators-legacy": "^1.3.4",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-es2015-loose": "^8.0.0",
    "babel-preset-react": "^6.24.1",
    "babel-preset-stage-1": "^6.24.1",

将高版本的babel配置做降级修改:
原本的babelrc

同步降级为:

{
  "presets": [
    ["es2015", { "loose": true }],
    "stage-1",
    "react"
  ],
  "plugins": ["transform-decorators-legacy", "react-hot-loader/babel"]
}

重新 npm run dev 问题解决


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM