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 问题解决

原文地址:https://www.cnblogs.com/dengxiaoning/p/14460939.html