小编Ars*_*zaq的帖子

出现错误:插件/预设文件不允许导出对象,只能导出函数

我在使用 webpack 和 babel 设置我的 React 应用程序时遇到了这个错误。我尝试更改 babel 的版本,但仍然出现相同的错误。我不明白问题出在哪里。

ERROR in ./src/index.jsx
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Plugin/Preset files are not allowed to export objects, only functions. In /home/arslan/Downloads/code/node_modules/babel-preset-es2015/lib/index.js
    at createDescriptor (/home/arslan/Downloads/code/node_modules/@babel/core/lib/config/config-descriptors.js:178:11)
    at items.map (/home/arslan/Downloads/code/node_modules/@babel/core/lib/config/config-descriptors.js:109:50)
    at Array.map (<anonymous>)
    at createDescriptors (/home/arslan/Downloads/code/node_modules/@babel/core/lib/config/config-descriptors.js:109:29)
    at createPresetDescriptors (/home/arslan/Downloads/code/node_modules/@babel/core/lib/config/config-descriptors.js:101:10)
    at presets (/home/arslan/Downloads/code/node_modules/@babel/core/lib/config/config-descriptors.js:47:19)
    at mergeChainOpts (/home/arslan/Downloads/code/node_modules/@babel/core/lib/config/config-chain.js:320:26)
    at /home/arslan/Downloads/code/node_modules/@babel/core/lib/config/config-chain.js:283:7
    at buildRootChain (/home/arslan/Downloads/code/node_modules/@babel/core/lib/config/config-chain.js:120:22)
    at loadPrivatePartialConfig 
Run Code Online (Sandbox Code Playgroud)

这是我的 Index.jsx 文件,它是根文件。

import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux'
import store from './store'
import …
Run Code Online (Sandbox Code Playgroud)

reactjs webpack babeljs webpack-dev-server babel-loader

5
推荐指数
1
解决办法
3751
查看次数