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

2023-07-30,,

运行项目是提示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配置做降级修改:

同步降级为:

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

重新 npm run dev 问题解决

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..doc》

下载本文的Word格式文档,以方便收藏与打印。