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